Search code examples
laravel-5.3

laravel 5.3 action with parameter doesn't work


I have problem with route action have parameters. this is my Web route :

Route::get('/services/[id]/[title]', 'SiteController@services');

and this is my blade link :

<a href="{{action('SiteController@services',['id'=>'4','title'=>'4'])}}" class="text-blue transition-5 padding-top-30 display-block"> More </a>

But when i click on this link i have this url :

http://localhost:8000/services/%5Bid%5D/%5Btitle%5D?id=4&title=4

and in wamp i cant see my pages , i have db not found error. but in localhost800 not problem :| help me please thansk all


Solution

  • First, your route variables should be with {} not []. So it should look like this;

    Route::get('/services/{id}/{title}', 'SiteController@services');
    

    Then check if you can actually get to that route by manually going to "/services/4/4".