创建新模型实例时,不会保存“slug”属性。我检查了var y = gameObject.transform.localEulerAngles.y;
方法中的creating
事件是否正在被调用。但是,在修补程序中,我可以看到属性中没有“slug”键。是什么赋予了?对于我的生活,我找不到自己的错误。
廷克:
boot
TicketType.php
App\Models\TicketType::create(['title'=>'My title']);
Illuminate\Database\QueryException with message 'SQLSTATE[HY000]: General error: 1364 Field 'slug' doesn't have a default value (SQL: insert into `ticket_types` (`title`, `updated_at`, `created_at`) values (my title, 2017-11-16 08:13:17, 2017-11-16 08:13:17))'
HasSlug.php
namespace App\Models;
use App\Models\Abstracts\TypeModelAbstract;
use App\Models\Interfaces\TypeModelInterface;
use App\Traits\HasSlug;
class TicketType extends TypeModelAbstract implements TypeModelInterface {
use HasSlug;
protected $fillable = [
'title',
'slug',
...
];
...
public static function boot() {
parent::boot();
static::creating(function ($item) {
$item->sluggable();
\Log::debug('slug is ' . $item->slug, $item->attributes);
// Here $item->slug is correct, but the slug is not in the attributes array
});
}
答案 0 :(得分:0)
卫生署!我对继承的特征有一个this.books$
。谢谢哈穆德!