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>
58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?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;
|
||
}
|
||
}
|