【问题标题】:Unable to assign roles or permissions to user (Laravel - nova permissions)无法为用户分配角色或权限(Laravel - nova 权限)
【发布时间】:2019-04-04 11:13:31
【问题描述】:

我将Laravel 5.7postgreSQLnova 一起用于管理面板。我还使用vyuldashev/nova-permission 来处理基于spatie/laravel-permission 构建的rbac CRUD。

在定义权限或角色时,nova 权限 CRUD 中的所有内容都很好。但问题是当我为用户分配权限或角色时,出现以下错误:

[10:50:18] LOG.error: SQLSTATE[42703]: Undefined column: 7 ERROR:  column "id" does not exist
LINE 1: ... "role_id", "model_type")
values
($1, $2, $3) returning "id" ^ (SQL: insert into "model_has_roles" ("model_id", "role_id", "model_type") 
values
 (198564523584, 1, App\Models\User\User) returning "id") {"userId":198564523584,"email":"b.sobhanbagheri@gmail.com","exception":{"errorInfo":["42703",7,"ERROR:  column \"id\" does not exist\nLINE 1: ... \"role_id\", \"model_type\") values ($1, $2, $3) returning \"id\"\n ^"]}}

我不确定究竟是什么破坏了查询。如果它与postgreSQL 有任何关系。任何帮助表示赞赏。

【问题讨论】:

  • 你能展示你如何向用户添加权限的代码吗?
  • @Ruub 我安装了这个包,一切都在后台发生。我在 mysql 或 mariadb 的其他项目中使用它没有这个问题:github.com/vyuldashev/nova-permission

标签: laravel postgresql eloquent laravel-nova


【解决方案1】:

通过将自动增量id 添加到我试图添加记录的表(到默认迁移)中,解决了我的问题。根据包代码和查询结构,postgreSQLlaravel 似乎不允许您插入到没有自动递增 id 的表中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-15
    • 2014-01-09
    • 2022-10-20
    • 2017-09-13
    • 2016-02-27
    • 2016-11-28
    • 2021-05-29
    • 2015-11-26
    相关资源
    最近更新 更多