Generische iCal-Kanäle mit Bestandsklärung und sicheren Exporten bereitstellen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m33s

This commit is contained in:
Lars committed 2026-10-27 17:14:45 +01:00
1 parent 6fe5bbc6e3
commit 783068501c
42 files changed
+2646 -248

No files matched your search

+38 -2
View File
@@ -3,6 +3,7 @@
namespace App\Models;
use App\Models\Concerns\BelongsToTenant;
use App\Models\Concerns\HasChannelProvenance;
use App\Observers\BlockedPeriodObserver;
use Carbon\CarbonInterface;
use Database\Factories\BlockedPeriodFactory;
@@ -13,17 +14,20 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Dates that are not bookable (own use, maintenance, bookings from portals).
* Like bookings, ends_on is the first free day again.
*/
#[ObservedBy(BlockedPeriodObserver::class)]
#[Fillable(['property_id', 'channel_id', 'starts_on', 'ends_on', 'reason', 'source', 'external_uid'])]
#[Fillable(['property_id', 'channel_id', 'origin_channel_id', 'starts_on', 'ends_on', 'reason', 'source', 'external_uid', 'needs_review', 'review_note', 'missing_imports', 'is_representation', 'canonical_block_id', 'linked_booking_id', 'export_approved', 'reviewed_at'])]
class BlockedPeriod extends Model
{
/** @use HasFactory<BlockedPeriodFactory> */
use BelongsToTenant, HasFactory;
use BelongsToTenant, HasChannelProvenance, HasFactory, SoftDeletes;
protected $attributes = ['is_representation' => false, 'export_approved' => true];
/**
* Get the attributes that should be cast.
@@ -35,6 +39,11 @@ protected function casts(): array
return [
'starts_on' => 'immutable_date',
'ends_on' => 'immutable_date',
'needs_review' => 'boolean',
'missing_imports' => 'integer',
'is_representation' => 'boolean',
'export_approved' => 'boolean',
'reviewed_at' => 'immutable_datetime',
];
}
@@ -54,6 +63,33 @@ public function channel(): BelongsTo
return $this->belongsTo(Channel::class);
}
/** @return BelongsTo<Channel, $this> */
public function originChannel(): BelongsTo
{
return $this->belongsTo(Channel::class);
}
/** @return BelongsTo<BlockedPeriod, $this> */
public function canonicalBlock(): BelongsTo
{
return $this->belongsTo(self::class, 'canonical_block_id')->withTrashed();
}
/** @return BelongsTo<Booking, $this> */
public function linkedBooking(): BelongsTo
{
return $this->belongsTo(Booking::class, 'linked_booking_id');
}
/** @param Builder<BlockedPeriod> $query
* @return Builder<BlockedPeriod>
*/
#[Scope]
protected function occupying(Builder $query): Builder
{
return $query->where('is_representation', false);
}
/**
* @param Builder<BlockedPeriod> $query
* @return Builder<BlockedPeriod>