chore: update document approval workflow and bug fixes
This commit is contained in:
57
Modules/ProjectManagement/app/Models/TaskDelay.php
Normal file
57
Modules/ProjectManagement/app/Models/TaskDelay.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\HasPublicIdentifier;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Modules\ProjectManagement\Enums\DelayReason;
|
||||
use Modules\ProjectManagement\Enums\WeatherCondition;
|
||||
|
||||
class TaskDelay extends Model
|
||||
{
|
||||
use HasPublicIdentifier;
|
||||
|
||||
protected $fillable = [
|
||||
'task_id',
|
||||
'reason_type',
|
||||
'weather_condition',
|
||||
'delay_date',
|
||||
'lost_hours',
|
||||
'notes',
|
||||
'reported_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'reason_type' => DelayReason::class,
|
||||
'weather_condition' => WeatherCondition::class,
|
||||
'delay_date' => 'date',
|
||||
'lost_hours' => 'decimal:2',
|
||||
];
|
||||
}
|
||||
|
||||
public function task(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Task::class);
|
||||
}
|
||||
|
||||
public function reporter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'reported_by');
|
||||
}
|
||||
|
||||
// --- Accessors ---
|
||||
|
||||
public function getIsWeatherRelatedAttribute(): bool
|
||||
{
|
||||
return $this->reason_type === DelayReason::Weather;
|
||||
}
|
||||
|
||||
public function getLostDaysAttribute(): float
|
||||
{
|
||||
return round((float) $this->lost_hours / 8, 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user