jrmypttrsn
2 months ago
288
7
Laravel

Missing required parameters error in production but works locally

Posted 2 months ago by jrmypttrsn

This is a strange one I've been fighting for the last 12ish hours. On my production app I'm getting the following error:

Missing required parameters for [Route: tasks.update] [URI: tasks/{task}]. (View: /home/forge/DOMAIN/resources/views/tasks/index.blade.php) 

My form action:

<form method="POST" action="{{ route('tasks.update', ['task' => $task->task_id]) }}">

My controller method:

 public function update(Task $task, Request $request)
    {
        if ($request->priority_score != $task->job->priority)
        {
            $task->job()->update([
                'priority' => $request->priority_score
            ]);

            return back()->with('success', 'Priority score successfully updated!');
        }

        $task->update($request->all());

        return back()->with('success', 'Task successfully updated!');
    }

And my routes/web.php

Route::post('/tasks/{task_id}', '[email protected]')->name('tasks.update');
Route::resource('tasks', 'TaskController');

I moved the update method to its own route in the hopes that might help the production issue, since it also works locally, but it did not.

I've cleared caches, run dump-autoload, all to no avail.

Thoughts?

Cross-posted on SO.

Please sign in or create an account to participate in this conversation.