I want to make a routing on laravel {{ route('import',[$p->id]) }} this are on my a href but when my cursor hovering on the button it preview import?1 not import/2 what is my mistake here?
3 Answers
You can define route as ->name('import') or 'as'=>'import' here.
Route::get('import/{id}','Controller@method')->name('import');
Or
Route::get('import/{id}',['as'=>'import','uses'=>'Controller@method']);
In href you can call as
<a href="{{ route('import',[$p->id]) }}">CLick</a>
If the named route defines parameters, you may pass the parameters as the second argument to the route function. The given parameters will automatically be inserted into the URL in their correct positions:
Route::get('user/{id}/profile', function ($id) {
//
})->name('profile');
$url = route('profile', ['id' => 1]);
//Url will be domain.com/user/1/profile.