attributes['password'] = Crypt::encrypt($value); } // before create admin, generate api_token public static function boot() { parent::boot(); self::creating(function ($admin) { // if not set api_token if (!$admin->api_token) { $admin->api_token = Str::random(60); } }); } }