Я недавно обновил приложение Laravel 5.1 до 5.2. Это работало нормально, но с момента обновления у меня возникла проблема. При попытке удалить один из моих моделей, я получаю следующее исключение:Исключение при попытке удалить модель в laravel 5.2
FatalErrorException in Model.php line 1011:
Class name must be a valid object or a string
URL, я нахожусь на:
/admin/roles/delete/4
Маршрут для него является:
Route::get('admin/roles/delete/{id}', ['as' => 'admin.roles.delete', 'uses' => 'Admin\[email protected]']);
код контроллера:
public function destroy($id)
{
$role = Role::find($id);
$role->delete();
Session::flash('message', '<div class="alert alert-success" role="alert">The role has been deleted.</div>');
return redirect(route('admin.roles'));
}
Режим л код:
<?php namespace App;
use Zizaco\Entrust\EntrustRole;
class Role extends EntrustRole
{
protected $fillable = ['name', 'display_name', 'description'];
}
Это, вероятно, стоит упомянуть, я использую Entrust пакет. Это содержимое моего файла конфигурации Доверьте:
<?php
/**
* This file is part of Entrust,
* a role & permission management solution for Laravel.
*
* @license MIT
* @package Zizaco\Entrust
*/
return [
/*
|--------------------------------------------------------------------------
| Entrust Role Model
|--------------------------------------------------------------------------
|
| This is the Role model used by Entrust to create correct relations. Update
| the role if it is in a different namespace.
|
*/
'role' => 'App\Role',
/*
|--------------------------------------------------------------------------
| Entrust Roles Table
|--------------------------------------------------------------------------
|
| This is the roles table used by Entrust to save roles to the database.
|
*/
'roles_table' => 'roles',
/*
|--------------------------------------------------------------------------
| Entrust Permission Model
|--------------------------------------------------------------------------
|
| This is the Permission model used by Entrust to create correct relations.
| Update the permission if it is in a different namespace.
|
*/
'permission' => 'App\Permission',
/*
|--------------------------------------------------------------------------
| Entrust Permissions Table
|--------------------------------------------------------------------------
|
| This is the permissions table used by Entrust to save permissions to the
| database.
|
*/
'permissions_table' => 'permissions',
/*
|--------------------------------------------------------------------------
| Entrust permission_role Table
|--------------------------------------------------------------------------
|
| This is the permission_role table used by Entrust to save relationship
| between permissions and roles to the database.
|
*/
'permission_role_table' => 'permission_role',
/*
|--------------------------------------------------------------------------
| Entrust role_user Table
|--------------------------------------------------------------------------
|
| This is the role_user table used by Entrust to save assigned roles to the
| database.
|
*/
'role_user_table' => 'role_user',
];
Я обновил этот вопрос, чтобы показать свой конфигурационный файл. Похоже, все названо правильно. – geoffs3310
Ваша конфигурация кэширована? Убедитесь, что вы очистили его, выполнив команду 'php artisan config: clear' –
Yep попробовал это, но по-прежнему получал ту же ошибку – geoffs3310