26 خطوط
1018 B
PHP
26 خطوط
1018 B
PHP
<?php
|
|
|
|
namespace App\Modules\Assignments\Domain;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Assignment extends Model
|
|
{
|
|
use HasUlids;
|
|
|
|
protected $fillable = ['organization_id', 'assignable_type', 'assignable_id', 'target_type', 'target_id', 'target_value', 'status', 'mandatory', 'starts_at', 'due_at', 'recurring_months', 'reminder_days', 'escalation_policy', 'source', 'assigned_by', 'cancelled_at'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return ['mandatory' => 'boolean', 'starts_at' => 'immutable_datetime', 'due_at' => 'immutable_datetime', 'cancelled_at' => 'immutable_datetime', 'escalation_policy' => 'array'];
|
|
}
|
|
|
|
public function users(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(User::class, 'assignment_users')->withPivot(['status', 'assigned_at', 'starts_at', 'due_at', 'completed_at', 'progress'])->withTimestamps();
|
|
}
|
|
}
|