Thursday, April 13, 2017

Laravel not redirecting (but HTML response seen in Network tab)

I have a fairly straightforward requirements: From one of the controller functions, I need to redirect the page to a named route and pass along some data.

What I tried the source controller function was this:

    // . . .
    $patent->save();
    return redirect()->route('patents.update', [$patent]);
}

The named route patents.update is defined in my routes/web.php as:

Route::get('patents/update', 'PatentsController@update')->name('patents.update');

And finally, the destination controller function:

public function update(Patent $patent) {
    return view('patents.update');
}

The problem is that when I run this, the page stays where it is, while the view I'm looking for is received as GET response in the Network tab in Chrome. Why's the redirect not working?



via dotslash

Advertisement