Add HL3D branding, Etsy Live/Draft paging and Projects lifecycle
Deploy HickLab3D Dashboard / Deploy to production (push) Failing after 23s
Deploy HickLab3D Dashboard / Deploy to production (push) Failing after 23s
Replace the old touchmark/PNG identity with the supplied lockup and monogram, segmented role-aware navigation, Live/Draft listing filters with generation-based cache invalidation, and admin Projects covering immutable file revisions, listing live pointers, and exact-decimal filament/packaging/shipping costing. Additive schema only; no Etsy publication. Isolated clone tests: 301 tests, 1162 assertions.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\ProjectCosting;
|
||||
use Database\Factories\ProjectCostSnapshotFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class ProjectCostSnapshot extends Model
|
||||
{
|
||||
/** @use HasFactory<ProjectCostSnapshotFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public const BASIS_ESTIMATE = 'estimate';
|
||||
|
||||
public const BASIS_ACTUAL = 'actual';
|
||||
|
||||
protected $fillable = [
|
||||
'project_id', 'revision_id', 'currency', 'basis', 'batch_units',
|
||||
'filament_total', 'packaging_total', 'shipping_total', 'grand_total',
|
||||
'source_reference', 'notes', 'recorded_by', 'recorded_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'filament_total' => 'decimal:4',
|
||||
'packaging_total' => 'decimal:4',
|
||||
'shipping_total' => 'decimal:4',
|
||||
'grand_total' => 'decimal:4',
|
||||
'recorded_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function project(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Project::class);
|
||||
}
|
||||
|
||||
public function revision(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ProjectRevision::class, 'revision_id');
|
||||
}
|
||||
|
||||
public function recorder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'recorded_by');
|
||||
}
|
||||
|
||||
public function lines(): HasMany
|
||||
{
|
||||
return $this->hasMany(ProjectCostLine::class, 'cost_snapshot_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* A release requires every cost category to have been explicitly costed —
|
||||
* even as an intentional zero — rather than merely recorded. A category left
|
||||
* null ("not costed") is incomplete and must block a release going live.
|
||||
*/
|
||||
public function isComplete(): bool
|
||||
{
|
||||
return $this->filament_total !== null
|
||||
&& $this->packaging_total !== null
|
||||
&& $this->shipping_total !== null;
|
||||
}
|
||||
|
||||
public function perUnitGrandTotal(): ?string
|
||||
{
|
||||
if ($this->grand_total === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ProjectCosting::perUnit((string) $this->grand_total, (int) $this->batch_units);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user