- Added ListinoRelationManager for managing price lists associated with models. - Introduced ImportaListiniAction for importing price lists from Excel files. - Created ListinoPrezzo model to represent price entries in the database. - Developed ListinoExcelParser for parsing Excel files containing price lists. - Implemented ListinoImporter to handle the import logic and associations. - Added migration for creating listino_prezzi table and converting measures to mm. - Updated frontend logic to handle new price list features and validations. - Enhanced tests for price list import and conversion functionalities.
36 lines
849 B
PHP
36 lines
849 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class ListinoPrezzo extends Model
|
|
{
|
|
protected $table = 'listino_prezzi';
|
|
|
|
protected $fillable = [
|
|
'modello_id', 'larghezza', 'altezza', 'prezzo',
|
|
];
|
|
|
|
protected $casts = [
|
|
'larghezza' => 'integer',
|
|
'altezza' => 'integer',
|
|
'prezzo' => 'float',
|
|
];
|
|
|
|
public function modello(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Modello::class);
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
// Le modifiche manuali dal pannello aggiornano la data del listino del modello.
|
|
$tocca = fn (ListinoPrezzo $prezzo) => $prezzo->modello?->update(['listino_aggiornato_at' => now()]);
|
|
|
|
static::saved($tocca);
|
|
static::deleted($tocca);
|
|
}
|
|
}
|