94938f24d7
Schema: - tire_sets (client/vehicle, season, size width/profile/diameter, brand/DOT, rims, tread JSON per position + tread_min cache, TPMS + sensor ids, photos) - tire_storage (location, season_label, stored/retrieved, check-in/out, fee) Models: - TireSet (HasMedia): sizeLabel, isStored, currentStorage, auto tread_min - TireStorage: durationDays, isActive Filament (new "Anvelope" nav group): - TireSetResource: specs form + per-position tread + TPMS + photo upload; table with size, season badge, min tread (red < 3mm), storage status - Check-in (location + period + fee → stored) / Check-out (→ retrieved) - StorageRelationManager (stay history); nav badge = sets currently stored Tests (6 new): - sizeLabel formatting; tread_min from positions; check-in active storage; check-out retrieved + duration; multiple stays per set; tenant isolation Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Tenant;
|
|
|
|
use App\Models\Concerns\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class TireStorage extends Model
|
|
{
|
|
use BelongsToTenant;
|
|
|
|
protected $table = 'tire_storage';
|
|
|
|
public const STATUSES = [
|
|
'stored' => 'În depozit',
|
|
'retrieved' => 'Ridicat',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'company_id', 'tire_set_id',
|
|
'location', 'season_label', 'status',
|
|
'checked_in_at', 'checked_out_at', 'fee', 'paid', 'notes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'checked_in_at' => 'datetime',
|
|
'checked_out_at' => 'datetime',
|
|
'fee' => 'decimal:2',
|
|
'paid' => 'boolean',
|
|
];
|
|
|
|
public function tireSet(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TireSet::class);
|
|
}
|
|
|
|
public function isActive(): bool
|
|
{
|
|
return $this->status === 'stored';
|
|
}
|
|
|
|
public function durationDays(): int
|
|
{
|
|
$end = $this->checked_out_at ?? now();
|
|
return (int) $this->checked_in_at?->diffInDays($end);
|
|
}
|
|
}
|