Files
GSB-Construction/Modules/ProjectManagement/app/Models/ProjectMaterialsEstimate.php
Christopher Boyles 64d4b331a8
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled
Additional Changes
2026-06-02 22:04:03 +08:00

41 lines
869 B
PHP

<?php
namespace Modules\ProjectManagement\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Modules\MasterData\Models\Material;
class ProjectMaterialsEstimate extends Model
{
protected $fillable = [
'project_id',
'material_id',
'estimated_qty',
'unit_cost',
];
protected function casts(): array
{
return [
'estimated_qty' => 'decimal:2',
'unit_cost' => 'decimal:2',
];
}
public function project(): BelongsTo
{
return $this->belongsTo(Project::class);
}
public function material(): BelongsTo
{
return $this->belongsTo(Material::class);
}
public function getLineTotalAttribute(): float
{
return (float) $this->estimated_qty * (float) $this->unit_cost;
}
}