Reputation: 57
Laravel 5.7 route with name not working but simple routing is working, i tried and found lot of answers but nothing is working for me , please help me on this
i tried this
Route::get('jobs/jobs-search', 'JobsController@job_listing')->name('jobssearch');
also tried this
Route::get('jobs/jobs-search', array('as' => 'jobssearch', 'uses' => 'JobsController@job_listing'));
Working with url: {{ url('jobs/jobs-search') }} //http://localhost/mzd/jobs/jobs-search
Not working accessing name rout {{ route('jobssearch') }} this show 404 page not found //http://localhost/mzd/jobssearch
i am using xampp 7.2.10 with laravel 5.7 this is my .htaccess
Options -MultiViews -Indexes
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
# Disable index view
Options -Indexes
# Hide a specific file
<Files .env>
Order allow,deny
Deny from all
</Files>
Image of my routes please check
Upvotes: 1
Views: 2169
Reputation: 51
If you verify the image of your routes, you should use route('jobs.jobssearch');
Upvotes: 0
Reputation: 14288
The url that is being generated is different that's why you get 404, if you notice jobs
is missing from your named route. So try this:
Route::get('/jobs/jobs-search', 'JobsController@job_listing')->name('jobssearch');
Notice the starting /
. And then check what route('jobssearch')
will return.
--- EDIT
Based on your routes you need to use route('jobs.jobssearch');
Upvotes: 2