Ad

Laravel Pathing In Link

- 1 answer

I am using same thing but result is different. In posts.blade.php i can call like this

<a href = "posts/{{post->id}}"edit>Edit</a>

But when i use same thing in rooms.blade.php indisde rooms folder i had to use like this.

<a href = "{{$room->id}}/edit" class = 'btn btn-primary'> Edit</a> 

It is really confusing me. Any solution? i want to add link for editing post inside room. I have tried many things but i dont understand.

My Route

 Route::get('/','[email protected]');
Route::get('/about', '[email protected]');
Route::get('/services', '[email protected]');
Route::get('/register', '[email protected]');
Route::get('/logout', '[email protected]');
Route::get('/posts', '[email protected]');
Route::resource('posts','PostsController');
Route::resource('rooms','RoomsController');
Auth::routes();

Route::get('/dashboard', '[email protected]');
Ad

Answer

You can give the name of the route

Foe example:

Route::get('/post/{id}', '[email protected]')->name('post.show');

And then call the blade

<a target="_blank" rel="nofollow noreferrer" href="{{ route('posts.show', [$id]) }}">Link to Resource {{ $id }}</a>
Ad
source: stackoverflow.com
Ad