cariboucreative's avatar

404 on Resource Route

I am getting a 404 status code on a laravel resource route when posting a model bound form. The form opening tag is as follows:

    {!!Form::model($project, ['route' => ['admin.projects.update', $project->id], 'method' => 'PUT', 'files' => true])!!}
    //Form content here
   //There are a few long select drops and its all pretty standard inputs so I won't include the contents for brevity
    {!! Form::close() !!}

And the resource route as it appears under routes:list is:

| Domain | Method | URI | Name | Action | Middleware | | | PUT | admin/projects/{projects} | admin.projects.update | App\Http\Controllers\Admin\AdminProjectsController@update |

and the controller:

    public function update(CreateProjectRequest $request, $id)
    {
    //this handles file upload and is working fine
     if($request->hasFile('images')){
                $files = $request->file('images');
                $this->project->doFileAdd($files);
            }
      $data = $request->all();
      $project = Project::findOrFail($id);
      $project->update($data);
      return redirect('admin/projects/edit/all');
    }

When I check the response in devtools, the payload is attached and the route url is correct. For example, if I am updating a project with an id of 150, the url is http://localhost:8888/project-name/public/admin/projects/150.

If I don't make any changes, the redirect from the controller works. If I only add files through the form it also works. It's when I change the text input data that I get the 404 which has me puzzled. Either it exists and can be found, or it doesn't. I've never had this issue using resourceful routing before and can't for the life of me solve the issue after a couple of hours of trying.

Any fresh eyes see where I am making a mistake?

0 likes
0 replies

Please or to participate in this conversation.