43 lines
1.0 KiB
PHP
43 lines
1.0 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;
|
|
|
|
class Task extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'tasks';
|
|
protected $guarded = [];
|
|
protected $casts = [
|
|
'title' => 'array',
|
|
'description' => 'array',
|
|
'example_text' => 'array',
|
|
];
|
|
|
|
public function emotion(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Emotion::class);
|
|
}
|
|
|
|
public function eventType(): BelongsTo
|
|
{
|
|
return $this->belongsTo(EventType::class, 'event_type_id');
|
|
}
|
|
|
|
public function taskCollection(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TaskCollection::class, 'collection_id');
|
|
}
|
|
|
|
public function assignedEvents(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Event::class, 'event_task', 'task_id', 'event_id')
|
|
->withTimestamps();
|
|
}
|
|
}
|