50 lines
1.1 KiB
PHP
50 lines
1.1 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;
|
|
|
|
class Event extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'events';
|
|
protected $guarded = [];
|
|
protected $casts = [
|
|
'date' => 'datetime',
|
|
'settings' => 'array',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
|
|
public function photos(): HasMany
|
|
{
|
|
return $this->hasMany(Photo::class);
|
|
}
|
|
|
|
public function taskCollections(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(
|
|
TaskCollection::class,
|
|
'event_task_collection',
|
|
'event_id',
|
|
'task_collection_id'
|
|
);
|
|
}
|
|
|
|
public function tasks(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Task::class, 'event_task', 'event_id', 'task_id')
|
|
->withTimestamps();
|
|
}
|
|
}
|
|
|