Files
LarsandCursor 8ebc1a3878 Assign the existing site to one landlord so stommer.info can run tenancy.
Seebad 0.3 stays in this release. With a single landlord every host still reaches the default website.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-23 12:00:11 +02:00

58 lines
1.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Models;
use App\Enums\PortalEmailStatus;
use App\Enums\PortalEmailType;
use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A notification e-mail of a portal (e.g. "new booking" from FeWo-direkt) and what the system did with it.
* Only a short excerpt is stored, not the whole e-mail.
*/
#[Fillable(['channel_id', 'message_id', 'from', 'subject', 'received_at', 'type', 'status', 'starts_on', 'ends_on', 'reference', 'blocked_period_id', 'excerpt', 'note'])]
class PortalEmail extends Model
{
use BelongsToTenant;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'type' => PortalEmailType::class,
'status' => PortalEmailStatus::class,
'received_at' => 'immutable_datetime',
'starts_on' => 'immutable_date',
'ends_on' => 'immutable_date',
];
}
/**
* @return BelongsTo<Channel, $this>
*/
public function channel(): BelongsTo
{
return $this->belongsTo(Channel::class);
}
/**
* @return BelongsTo<BlockedPeriod, $this>
*/
public function blockedPeriod(): BelongsTo
{
return $this->belongsTo(BlockedPeriod::class);
}
public function period(): ?string
{
return $this->starts_on && $this->ends_on ? $this->starts_on->format('d.m.Y').' – '.$this->ends_on->format('d.m.Y') : null;
}
}