Files
fotospiel-app/app/Models/Task.php

44 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;
use Illuminate\Database\Eloquent\SoftDeletes;
class Task extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'tasks';
protected $guarded = [];
protected $casts = [
'due_date' => 'datetime',
'is_completed' => 'bool',
];
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();
}
}