我创建一个迁移
Schema::create('roles', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('label')->nullable();
$table->timestamps();
});
Schema::create('permissions', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('label')->nullable();
$table->timestamps();
});
Schema::create('permission_role', function (Blueprint $table) {
$table->integer('role_id')->unsigned();
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
$table->integer('permission_id')->unsigned();
$table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
$table->primary(['role_id' , 'permission_id']);
});
Schema::create('role_user', function (Blueprint $table) {
$table->integer('role_id')->unsigned();
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->primary(['role_id' , 'user_id']);
});
Run Code Online (Sandbox Code Playgroud)
我在 CMD 中写的任何内容php artisan migrate and composer dumpautoload and php artisan serve and...都会看到此错误。我也删除了数据库并创建了一个新数据库。
[Illuminate\Database\QueryException] SQLSTATE[42S02]:未找到基表或视图:1146 表“prj_roocket.permissions”不存在(SQL:select * from
permissions)[PDOException] SQLSTATE[42S02]:未找到基表或视图:1146 表“prj_roocket.permissions”不存在
此错误是由函数给出getPermissions在AuthServiceProvider(或其他地方你确定你的身份验证服务提供商)。
可能你的函数是这样的:
protected function getPermissions()
{
return Permission::with('roles')->get();
}
Run Code Online (Sandbox Code Playgroud)
尝试将函数getPermissions替换为:
protected function getPermissions()
{
try {
return Permission::with('roles')->get();
} catch (\Exception $e) {
return [];
}
}
Run Code Online (Sandbox Code Playgroud)
然后再次运行php artisan migrate。
注意:使用此修复程序不会危及系统安全。
| 归档时间: |
|
| 查看次数: |
9887 次 |
| 最近记录: |