coreui / coreui-free-laravel-admin-template

CoreUI Free Laravel Bootstrap Admin Template
https://coreui.io/laravel/
MIT License
620 stars 354 forks source link

Need to fix routes for Route::resource for Laravel 8 #76

Open n00bman opened 2 years ago

n00bman commented 2 years ago

If you install this template then you can get this errors

Unknown named parameter $note ... Unknown named parameter $user

From official documentation:

By default, Route::resource will create the route parameters for your resource routes based on the "singularized" version of the resource name.

So for routes that generates using resource there should be methods in controllers with appropriate param names. But in current controllers this param names like $id and not like singularized version. So we should change routes or controller param names. the easy way to fix route files like this:

Route::resource('notes', 'NotesController')->parameters([ 'notes' => 'id']); ... Route::resource('users', 'UsersController')->except( ['create', 'store'] )->parameters([ 'users' => 'id']);

and etc.