feat: Initialize core application structure including authentication, role-based dashboards, service task management, and integration workflows.
This commit is contained in:
79
app/Models/ServiceTask.php
Normal file
79
app/Models/ServiceTask.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class ServiceTask extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['status', 'completed_at', 'validated_by'])
|
||||
->logOnlyDirty()
|
||||
->dontSubmitEmptyLogs();
|
||||
}
|
||||
|
||||
public function state(): \App\States\ServiceTask\ServiceTaskState
|
||||
{
|
||||
return match ($this->status) {
|
||||
\App\Enums\ServiceTaskStatus::Pending => new \App\States\ServiceTask\PendingState($this),
|
||||
\App\Enums\ServiceTaskStatus::InProgress => new \App\States\ServiceTask\InProgressState($this),
|
||||
\App\Enums\ServiceTaskStatus::WaitingValidation => new \App\States\ServiceTask\WaitingValidationState($this),
|
||||
\App\Enums\ServiceTaskStatus::Completed => new \App\States\ServiceTask\CompletedState($this),
|
||||
\App\Enums\ServiceTaskStatus::Rejected => new \App\States\ServiceTask\RejectedState($this),
|
||||
default => throw new \Exception("Unknown state: {$this->status->value}"),
|
||||
};
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'integration_request_id',
|
||||
'service_id',
|
||||
'status',
|
||||
'sla_deadline',
|
||||
'started_at',
|
||||
'completed_at',
|
||||
'validated_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'status' => \App\Enums\ServiceTaskStatus::class,
|
||||
'sla_deadline' => 'datetime',
|
||||
'started_at' => 'datetime',
|
||||
'completed_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function integrationRequest()
|
||||
{
|
||||
return $this->belongsTo(IntegrationRequest::class);
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function validator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'validated_by');
|
||||
}
|
||||
|
||||
public function taskItems()
|
||||
{
|
||||
return $this->hasMany(TaskItem::class);
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable');
|
||||
}
|
||||
|
||||
public function attachments()
|
||||
{
|
||||
return $this->hasMany(Attachment::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user