The missing route in Laravel Route::resource…

The Route::resource method in routes.php Laravel 5 is brilliant. It saves time setting up simple CRUD routes and consolidates lots of routes into one method.

However, I’m not sure the Create and Update route both have a pre-route for the form however Destroy doesn’t?

I know the Store and Update commands both need to have a form of data fed to them, however… all my Destroy commands need a page to check the user is sure they want to delete the resource. So all my routes resource calls have this “delete” GET with them,

Route::resource('taxonomy', 'TaxonomyController');
Route::get('taxonomy/{id}/delete', [
'as' => 'taxonomy.delete', 'uses' => 'TaxonomyController@delete'
]);

Otherwise, people are tempted to use a Javascript confirm box as the only way to check people want to delete something first. However, that’s a bit dumb 🙂 JS alert boxes are fiddly, also don’t fit with most site’s design styles and if your browser has JS off, your user is screwed.

By Dan Course

Senior Instructional Designer. Partnerships, people, products, delivery, agile tech and online edu. Naturally curious, innovative and willing to challenge the status quo.

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: