'bool', 'stripalarms' => 'bool', 'stripattachments' => 'bool', ]; /** relationship to meta row */ public function meta() { return $this->hasOne(\App\Models\CalendarMeta::class, 'subscription_id'); } /** * Create a remote calendar subscription and its UI metadata (calendar_meta). */ public static function createWithMeta(User $user, array $data): self { return DB::transaction(function () use ($user, $data) { /** insert into calendarsubscriptions */ $sub = self::create([ 'uri' => (string) Str::uuid(), 'principaluri' => $user->principal_uri, 'source' => $data['source'], 'displayname' => $data['displayname'] ?? $data['source'], 'calendarcolor' => $data['calendarcolor'] ?? null, 'refreshrate' => $data['refreshrate'] ?? 'P1D', 'calendarorder' => 0, 'striptodos' => false, 'stripalarms' => false, 'stripattachments' => false, 'lastmodified' => now()->timestamp, ]); /** create corresponding calendar_meta row */ DB::table('calendar_meta')->insert([ 'subscription_id' => $sub->id, 'is_remote' => true, 'title' => $sub->displayname, 'color' => $sub->calendarcolor ?? '#1a1a1a', 'color_fg' => contrast_text_color($sub->calendarcolor ?? '#1a1a1a'), 'is_shared' => true, 'created_at' => now(), 'updated_at' => now(), ]); return $sub; }); } }