Erro将行添加到spatie / laravel-permission插件表

时间:2018-08-24 07:46:11

标签: postgresql laravel-5 permissions

在我的具有“ spatie / laravel-permission”的Laravel 5.6 / PostgreSQL 10.5应用程序中:“ ^ 2.16”插件 我想添加1行:

        $newModelHasPermission                = new ModelHasPermission();
        $newModelHasPermission->permission_id = 1;
        $newModelHasPermission->model_type    = (new MyAppModel)->pgEscape("App\User");
        $newModelHasPermission->model_id      = 12;
        $newModelHasPermission->save();

我收到错误消息:

   "message": "SQLSTATE[42601]: Syntax error: 7 ERROR:  zero-length delimited identifier at or near \"\"\"\"\nLINE 1: ..., \"model_type\", \"model_id\") values ($1, $2, $3) returning \"\"\n                                                                     ^ (SQL: insert into \"rt_model_has_permissions\" (\"permission_id\", \"model_type\", \"model_id\") values (1, App\\User, 12) returning \"\")",
    "exception": "Illuminate\\Database\\QueryException",

模型声明具有:

 <?php
namespace App;

use DB;
use App\MyAppModel;
use App\User;
use App\library\ListingReturnData;
use App\Http\Traits\funcsTrait;

class ModelHasPermission extends MyAppModel
{

    protected $table = 'model_has_permissions';
    public $timestamps = false;

    use funcsTrait;

    protected static function boot() {
        parent::boot();
    }

    public function permission()
    {
        return $this->belongsTo('App\Permission');
    }

...

为什么出错以及如何解决?

谢谢!

0 个答案:

没有答案