kithkin/app/Models/CalendarInstance.php

37 lines
805 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class CalendarInstance extends Model
{
protected $table = 'calendarinstances';
public $timestamps = false;
protected $fillable = [
'calendarid',
'principaluri',
'uri',
'displayname',
'description',
'calendarcolor',
'timezone'
];
public function calendar(): BelongsTo
{
return $this->belongsTo(Calendar::class, 'calendarid');
}
public function caldavUrl(): string
{
// e.g. https://kithkin.lan/dav/calendars/1/48f888f3-c5c5-…/
return url(
'/dav/calendars/' .
auth()->user()->email . '/' .
$this->uri . '/'
);
}
}