36 lines
832 B
PHP
36 lines
832 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
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
|
|
{
|
|
protected $guarded = [];
|
|
|
|
public function path()
|
|
{
|
|
return '/events/' . $this->id;
|
|
}
|
|
|
|
public function category() :BelongsTo
|
|
{
|
|
return $this->belongsTo(EventCategory::class, 'category_id');
|
|
}
|
|
|
|
public function guests() :BelongsToMany
|
|
{
|
|
return $this->belongsToMany(User::class, 'event_guest')
|
|
->withPivot('is_staff', 'validated_at')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function emailedGuests() :HasMany
|
|
{
|
|
return $this->hasMany(EventGuestsNonUsers::class, 'event_id');
|
|
}
|
|
}
|