laravel调试器向我显示此错误:
特质方法启动尚未应用,因为与App \ User上的其他特征方法存在冲突
如果我删除了其中一种特质,Uuids或Entrust,则不会显示错误。但是我都需要它们。那我该如何解决呢?'
我正在使用laravel 5.8
谢谢!
namespace App;
use Zizaco\Entrust\Traits\EntrustUserTrait;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Uuids;
use EntrustUserTrait;
}
特质Uuid
<?php
namespace App;
use Webpatser\Uuid\Uuid;
trait Uuids
{
/**
* Boot function from laravel.
*/
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->{$model->getKeyName()} = Uuid::generate(5,'test', Uuid::NS_DNS);
});
}
}
我认为这与启动功能有关
答案 0 :(得分:0)
<?php
namespace App;
use Webpatser\Uuid\Uuid;
trait Uuids
{
/**
* Boot function from laravel.
*/
protected static function bootUuids()
{
static::creating(function ($model) {
$model->{$model->getKeyName()} = (string) Uuid::generate(4);
});
}
}
参考:SQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Table