mein-sterntours/dev/backups/phase2-offers-2026-04-17/PATCHES/Booking.php.full.diff
2026-04-17 17:19:11 +02:00

110 lines
3 KiB
Diff

diff --git a/app/Models/Booking.php b/app/Models/Booking.php
index 79a91ba..f3bf11c 100644
--- a/app/Models/Booking.php
+++ b/app/Models/Booking.php
@@ -9,6 +9,7 @@ namespace App\Models;
use Carbon\Carbon;
use App\Services\Util;
use App\Services\Passolution;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
@@ -18,7 +19,7 @@ use Illuminate\Database\Eloquent\Collection;
* @property int $id
* @property Carbon $booking_date
* @property int $customer_id
- * @property int $lead_id
+ * @property int $inquiry_id
* @property bool $new_drafts
* @property int $sf_guard_user_id
* @property int $branch_id
@@ -203,13 +204,16 @@ use Illuminate\Database\Eloquent\Collection;
*/
class Booking extends Model
{
+ use HasFactory;
+
protected $connection = 'mysql';
protected $table = 'booking';
protected $casts = [
'customer_id' => 'int',
- 'lead_id' => 'int',
+ 'inquiry_id' => 'int',
+ 'offer_id' => 'int',
'new_drafts' => 'bool',
'sf_guard_user_id' => 'int',
'branch_id' => 'int',
@@ -237,25 +241,24 @@ class Booking extends Model
'is_rail_fly' => 'bool',
'comfort' => 'bool',
'airline_ids' => 'array',
- 'participant_pass' => 'bool'
- ];
-
- protected $dates = [
- 'booking_date',
- 'start_date',
- 'end_date',
- 'participant_birthdate',
- 'final_payment_date',
- 'refund_date',
- 'lawyer_date',
- 'xx_tkt_date'
-
- ];
+ 'participant_pass' => 'bool',
+ 'booking_date' => 'datetime',
+ 'start_date' => 'datetime',
+ 'end_date' => 'datetime',
+ 'participant_birthdate' => 'datetime',
+ 'final_payment_date' => 'datetime',
+ 'refund_date' => 'datetime',
+ 'lawyer_date' => 'datetime',
+ 'xx_tkt_date' => 'datetime',
+ ];
+
+
protected $fillable = [
'booking_date',
'customer_id',
- 'lead_id',
+ 'inquiry_id',
+ 'offer_id',
'new_drafts',
'sf_guard_user_id',
'branch_id',
@@ -392,9 +395,29 @@ class Booking extends Model
return $this->belongsTo(Customer::class);
}
+ /**
+ * Lead/Inquiry der Buchung.
+ * FK-Spalte `inquiry_id` (vormals `lead_id` — Modul 3 Phase 2 Rename).
+ * Methodenname bleibt `lead()` für Legacy-Kompatibilität; {@see self::inquiry()}
+ * ist der fachlich korrekte Alias und sollte in neuem Code verwendet werden.
+ */
public function lead()
{
- return $this->belongsTo(Lead::class);
+ return $this->belongsTo(Lead::class, 'inquiry_id');
+ }
+
+ public function inquiry()
+ {
+ return $this->belongsTo(Lead::class, 'inquiry_id');
+ }
+
+ /**
+ * Angebot, aus dem diese Buchung entstanden ist (Modul 6, Ticket B8).
+ * Nullable — nicht jede Buchung hat einen Angebots-Vorlauf.
+ */
+ public function offer()
+ {
+ return $this->belongsTo(\App\Models\Offer::class);
}
public function sf_guard_user()