Doppelbuchungen nur einmal melden und im Postfach der Verwaltung zeigen
Der Kalenderabgleich alle 5 Minuten hat jede fortbestehende Ueberschneidung erneut gemailt. ReportChannelConflicts legt jede Ueberschneidung einmal im neuen Postfach (InboxMessage, Fingerabdruck je Mandant) ab und mailt nur neue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
876a0a20f3
commit
b9225f5fb8
17 files changed
+593
-15
No files matched your search
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\InboxMessageKind;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\InboxMessageFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* A message in the admin inbox ("Postfach"). The fingerprint identifies the finding, so the same
|
||||
* finding is posted – and e-mailed – only once per landlord (App\Support\Inbox).
|
||||
*/
|
||||
#[Fillable(['property_id', 'channel_id', 'kind', 'fingerprint', 'subject', 'body', 'action_url', 'read_at'])]
|
||||
class InboxMessage extends Model
|
||||
{
|
||||
/** @use HasFactory<InboxMessageFactory> */
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'kind' => InboxMessageKind::class,
|
||||
'read_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Property, $this>
|
||||
*/
|
||||
public function property(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Property::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Channel, $this>
|
||||
*/
|
||||
public function channel(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Channel::class);
|
||||
}
|
||||
|
||||
public function isRead(): bool
|
||||
{
|
||||
return $this->read_at !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<InboxMessage> $query
|
||||
* @return Builder<InboxMessage>
|
||||
*/
|
||||
#[Scope]
|
||||
protected function unread(Builder $query): Builder
|
||||
{
|
||||
return $query->whereNull('read_at');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user