feat: add previous configuration handling for user selections in quotes
- Implemented session storage management for the last configuration choices made by the user. - Added functionality to prompt users when changing models to retain their previous selections. - Introduced methods to apply previous choices to the newly loaded model, including finishes, handles, glass types, and options. - Enhanced user experience by ensuring selections are automatically applied where applicable.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Gruppo di opzioni del configuratore (es. telaio, profili extra, motore): come si
|
||||
* presenta nel menu e quale modulo del modello lo rende visibile.
|
||||
*/
|
||||
class GruppoOpzioni extends Model
|
||||
{
|
||||
protected $table = 'gruppi_opzioni';
|
||||
|
||||
public const UI = [
|
||||
'radio' => 'Pulsanti con icona, una scelta',
|
||||
'multipla' => 'Pulsanti con icona, più scelte (anche nessuna)',
|
||||
'select' => 'Menu a tendina',
|
||||
'nessuna' => 'Nessuno: solo prezzo (es. tipo finitura)',
|
||||
];
|
||||
|
||||
public const SEZIONI = [
|
||||
'sistema' => 'Sistema (telaio, apertura...)',
|
||||
'accessori' => 'Accessori (maniglia, cerniere...)',
|
||||
];
|
||||
|
||||
protected $fillable = ['codice', 'etichetta', 'ui', 'sezione', 'modulo', 'ordine'];
|
||||
|
||||
protected $casts = ['ordine' => 'integer'];
|
||||
|
||||
public function opzioni(): HasMany
|
||||
{
|
||||
return $this->hasMany(Opzione::class, 'gruppo', 'codice');
|
||||
}
|
||||
|
||||
/** @return Collection<string,GruppoOpzioni> per codice, nell'ordine del menu */
|
||||
public static function perCodice(): Collection
|
||||
{
|
||||
return static::query()->orderBy('ordine')->orderBy('id')->get()->keyBy('codice');
|
||||
}
|
||||
|
||||
/** @return array<string,string> codice => etichetta */
|
||||
public static function etichette(): array
|
||||
{
|
||||
return static::query()->orderBy('ordine')->orderBy('id')->pluck('etichetta', 'codice')->all();
|
||||
}
|
||||
|
||||
public function haControllo(): bool
|
||||
{
|
||||
return $this->ui !== 'nessuna';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user