54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Swindon\FilamentHashids\Traits\HasHashid;
|
|
|
|
class TaskAssignment extends Model
|
|
{
|
|
use HasFactory, HasHashid;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'start_date' => 'date',
|
|
'end_date' => 'date',
|
|
];
|
|
}
|
|
|
|
public function cooperation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Cooperation::class);
|
|
}
|
|
|
|
public function reports(): HasMany
|
|
{
|
|
return $this->hasMany(Report::class);
|
|
}
|
|
|
|
public function rejectionReasons(): MorphMany
|
|
{
|
|
return $this->morphMany(RejectionReason::class, 'rejectable');
|
|
}
|
|
|
|
public function mediaTaskAssignments(): HasMany
|
|
{
|
|
return $this->hasMany(MediaTaskAssignment::class);
|
|
}
|
|
|
|
public function partnerMedias(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(PartnerMedia::class, 'media_task_assignment')
|
|
->withPivot(['status'])
|
|
->withTimestamps();
|
|
}
|
|
}
|