'float', 'minimo_mq' => 'float', 'roughness' => 'float', 'metalness' => 'float', 'opacita' => 'float', 'bump_scala' => 'float', 'predefinito' => 'boolean', 'ordine' => 'integer', 'attivo' => 'boolean', ]; public function sistema(): BelongsTo { return $this->belongsTo(Sistema::class); } public function scopeAttivi(Builder $query): Builder { return $query->where('attivo', true)->orderBy('ordine')->orderBy('id'); } protected static function booted(): void { // Un solo elemento predefinito per sistema. static::saved(function (self $record): void { if ($record->predefinito && ($record->wasRecentlyCreated || $record->wasChanged('predefinito'))) { static::query() ->where('sistema_id', $record->sistema_id) ->whereKeyNot($record->getKey()) ->update(['predefinito' => false]); } }); } }