试图知道这些事件何时触发;简单的课程如下;然而,在修修补补中,没有发生任何这些事件!
答案班
class Answer extends Model{
protected $fillable=['body','votes_count'];
public static function boot()
{
parent::boot();
static::retrieved(function ($answer){
$answer->body= "answer retrieved event";
});
static::created(function ($answer){
$answer->body= "=== answer created event===";
});
static::updated(function ($answer){
$answer->body= "answer updated event ";
});
}}
修补程序命令
$ a = App \ answer :: find(1) =>应用\答案{#2960 编号:1 user_id:2 第2个问题, 正文:“ 500”, 票数:440, created_at:“ 2019-04-18 10:51:21”, Updated_at:“ 2019-04-18 16:31:35”, }