有时,需要在 create 时自动生成一些字段的值,而编辑时该字段不可改变。
public static function boot()
{
parent::boot();
self::creating(function($model){
$model->order_id = Utils::generate_random_order_id();
});
}
有时,需要在 create 时自动生成一些字段的值,而编辑时该字段不可改变。
public static function boot()
{
parent::boot();
self::creating(function($model){
$model->order_id = Utils::generate_random_order_id();
});
}