我使用的多表登录,怎么把权限跟我的admin表关联呢?查询语句报错是这样的:Base table or view not found: 1146 Table ‘cailanbao.clb_admin_role’ doesn’t exist (SQL: select clb_roles.*, clb_admin_role.admin_id as pivot_admin_id, clb_admin_role.role_id as pivot_role_id, clb_admin_role.created_at as pivot_created_at, clb_admin_role.updated_at as pivot_updated_at from clb_roles inner join clb_admin_role on clb_roles.id = clb_admin_role.role_id where clb_admin_role.admin_id = 1
@JellyBool 我照着写的代码,提示这样的错误,怎么解决,是什么问题呢?我的是laravel5.3
Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation (View: D:\xampp\htdocs\lel_acl\resources\views\posts\show.blade.php)
in Model.php line 2709
at CompilerEngine->handleViewException(object(LogicException), ‘1’) in PhpEngine.php line 44
at PhpEngine->evaluatePath(‘D:\xampp\htdocs\lel_acl\storage\framework\views/aa12ebc811325182351306a629b880dc19966173.php’, array(’__env’ => object(Factory), ‘app’ => object(Application), ‘errors’ => object(ViewErrorBag), ‘post’ => object(Post))) in CompilerEngine.php line 59
at CompilerEngine->get(‘D:\xampp\htdocs\lel_acl\resources\views/posts/show.blade.php’, array(’__env’ => object(Factory), ‘app’ => object(Application), ‘errors’ => object(ViewErrorBag), ‘post’ => object(Post))) in View.php line 149
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in Response.php line 45
at Response->setContent(object(View)) in Response.php line 201
at Response->__construct(object(View)) in Router.php line 1028
at Router->prepareResponse(object(Request), object(View)) in Router.php line 654
at Router->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 54
Whoops, looks like something went wrong.
(2/2) QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'redis.admin_role' doesn't exist (SQL: select `roles`.*, `admin_role`.`admin_id` as `pivot_admin_id`, `admin_role`.`role_id` as `pivot_role_id` from `roles` inner join `admin_role` on `roles`.`id` = `admin_role`.`role_id` where `admin_role`.`admin_id` = 1)
Psy Shell v0.8.15 (PHP 5.6.27 鈥?cli) by Justin Hileman
>>> namespace App;
>>> $role = new Role;
=> App\Role {#711}
>>> $role->name='admin';
=> "admin"
>>> $role->label='Admin';
=> "Admin"
>>> $role->save();
=> true
>>> $permission = new Permission;
=> App\Permission {#117}
>>> $permission->name='edit_form';
=> "edit_form"
>>> $permission->label='edit the form';
=> "edit the form"
>>> $permission->save();
=> true
>>> $role->givePermission($permission);
PHP Fatal error:Call to a member function save() on null in F:\www\test.dev\app\Role.php on line 19
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to a member function save() on null