'bool', 'is_free' => 'bool', ]; /** * Map attribute names to enum classes. * * @var array */ protected $enumCasts = [ 'mode' => DeliveryModeEnum::class ]; /** * Perform any actions required after the model boots. * * @return void */ protected static function booted() { // * EVENT CLOSURES. static::creating(function (self $model) { throw new \RuntimeException("Creating {$model->mode} is not allowed", 1); }); static::updated(function (self $model) { self::removeCached(); self::flashStatus($model, true); }); static::deleting(function (self $model) { throw new \RuntimeException("Deleting {$model->mode} is not allowed", 1); }); } // * METHODS /** * Query available delivery Methods * * @return \Illuminate\Database\Eloquent\Builder */ public static function availables(): Builder { return self::where('status', true); } }