I have the following in my web.php
:
Route::resource('/job', 'JobController');
Linked to the controller, I have the usual CRUD methods, and some work so for example going to joben.app/job/1
:
public function show(Job $job)
{
//
dd($job);
}
However, whenever I navigate to job.app/job
I get a 404 error, and the same whenever I post to job.app/job
The code worked fine before and I haven't changed anything, I've attempted reinstalling Valet and also using Artisans own dev server to view and post to the pages and still have the same result
Where can I start looking?
Edit: Here is my route list for the Job controller (sorry for formatting)
| | GET|HEAD | job | job.index | App\Http\Controllers\JobController@index
| | POST | job | job.store | App\Http\Controllers\JobController@store | web || | GET|HEAD | job/create | job.create | App\Http\Controllers\JobController@create | web |
| | PUT|PATCH | job/{job} | job.update | App\Http\Controllers\JobController@update | web |
| | DELETE | job/{job} | job.destroy | App\Http\Controllers\JobController@destroy | web |
| | GET|HEAD | job/{job} | job.show | App\Http\Controllers\JobController@show | web |
| | GET|HEAD | job/{job}/edit | job.edit | App\Http\Controllers\JobController@edit | web |
and here is the controller code - http://codepad.org/vgot10GN
UPDATE AND SOLUTION:
Ok so this was a pretty unique problem, but it might be happening to you.
I was storing images in public folder - as a test for file uploads under a directory named job
. Naturally, as the NGINX root for the files is the public folder, when posting to /job
NGINX first assumed to go to the folder named job
in the public folder.
Which in this instance was just a folder containing an image.
So after deleting this folder and reattempting it then worked.