0

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 3

2

In routes you should name the routes and pass the parameters there as well. For example

Route::get('/import/{id}','AnyController@controllerFunction')->name('import');

Then in views you can call the route function as you did.

{{ route('import',[$p->id]) }}
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

Try This

{{ route('import/'.$projects->id) }}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.