Laravel Backpack Create Model 时生成随机值,该字段在用户界面不可见

文章目录

    有时,需要在 create 时自动生成一些字段的值,而编辑时该字段不可改变。

    public static function boot()
    {
        parent::boot();
    
        self::creating(function($model){
            $model->order_id = Utils::generate_random_order_id();
        });
    
    }