39 lines
974 B
PHP
39 lines
974 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
class Calendar extends Model
|
|
{
|
|
protected $table = 'calendars'; // Sabre table
|
|
public $timestamps = false; // no created_at/updated_at
|
|
|
|
/* add mass-assignment for these cols */
|
|
protected $fillable = [
|
|
'displayname',
|
|
'description',
|
|
'timezone',
|
|
];
|
|
|
|
/* all event components (VEVENT, VTODO, …) */
|
|
public function events(): HasMany
|
|
{
|
|
return $this->hasMany(Event::class, 'calendarid'); // FK in calendarobjects
|
|
}
|
|
|
|
/* ui-specific metadata (color, sharing flags, json settings) */
|
|
public function meta(): HasOne
|
|
{
|
|
return $this->hasOne(CalendarMeta::class, 'calendar_id');
|
|
}
|
|
|
|
/* get instance */
|
|
public function instances()
|
|
{
|
|
return $this->hasMany(CalendarInstance::class, 'calendarid');
|
|
}
|
|
}
|