laravel get route parameters code example
Example 1: route optional parameter laravel
Route::get('user/{name?}', function ($name = null) {
return $name;
});
Route::get('user/{name?}', function ($name = 'John') {
return $name;
});
Example 2: laravel get route
Route::get('foo', function () {
return 'Hello World';
});
Example 3: laravel route param blade
<a class="nav-link" href=" {{ route('profiles.show',$logged_user) }}">
Example 4: named route with parameter laravel
Route::get('/menu/{category}/{product}/{item}', ['as' => 'named.route' , 'uses' => 'MenuController@listItem']);
route('named.route', ['category' => $category->id, 'product' => $product->id, 'item' => $item->id]);
Example 5: laravel get route
Route::get('/user', 'UserController@index');
Example 6: delete route method in laravel
<form method="POST" action="{{ route('route.name', [ 'id'=> $item->id ]) }}">
@csrf
<input type="hidden" name="_method" value="DELETE">
<button type="submit" class="btn btn-danger btn-icon">
<i data-feather="delete"></i>
</button>
</form>