lundi 4 juillet 2016

Laravel redirect after delete item

In my Laravel app, I want to delete an item and redirect immediately after that to the home page. Ideally, I want to do this purely in the routes file:

Route::get('event/{event}/delete', ['as' => 'events_delete', 'uses' => 'EventsController@destroy', function () {
    return Redirect::route('events_list');
}] );

In my destroy function I have the following:

public function destroy(Event $event)
{
    $event->delete();
}

The delete itself works (after refresh), but the redirect part does not seem to work. How can I redirect to the homepage immediately after the delete happened?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire