mercredi 31 octobre 2018

NotFoundHttpException error on post method Laravel 5.1

I got error NotFoundHttpException below

Error

Here is my route

Route::post('/ticket/{slug?}/edit', 'TicketsController@update');

My function update on TicketController

public function update($slug, TicketFormRequest $request)
{
    $ticket = Ticket::whereSlug($slug)->firstOrFail();
    $ticket->title = $request->get('title');
    $ticket->content = $request->get('content');
    if($request->get('status') != null) {
        $ticket->status = 0; } else {
    $ticket->status = 1;
}
$ticket->save();
return redirect(action('TicketsController@edit', $ticket->slug))->with('status', 'The ticket '.$slug.' has been updated!');

}

My function edit

 public function edit($slug)
{
    $ticket = Ticket::whereSlug($slug)->firstOrFail();
    return view('tickets.edit', compact('ticket'));
}

Am I missed something? I think my routes was right, maybe my update function is wrong



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire