attributes['password'] = bcrypt($value); } // before create admin, generate api_token public static function boot() { parent::boot(); self::creating(function ($admin) { if (app()->environment('production')) { $admin->api_token = Str::random(60); } else { $admin->api_token = 123456; } }); } }