mein-sterntours/app/Models/BookingStorno.php
Phase-1-Rollback-Agent e3dc1afd8e WIP: Sicherheitsnetz vor Phase-1-R\u00fcckbau
Enth\u00e4lt gemischt: Laravel-10-Upgrade + Phase 1 (Contacts-Modul, Duplicats-Commands,
Soft-Delete+Merge-Fields) + Phase 2 Code-Umstellungen (inquiry_id, $table='contacts'/'inquiries')
+ Offers-Modul (Migrationen, Models, offer_id in Booking, offer-Disk in filesystems.php).

Phase 2 + Offers werden im folgenden Commit nach dev/backups/phase2-offers-2026-04-17/
verschoben, damit der Workspace auf Phase-1-only (= Test-System-Stand) reduziert ist
und direkt auf Live deploybar wird.

Tarball-Backup zus\u00e4tzlich unter: ../backups-safety/workspace-pre-phase1-rollback-2026-04-17.tar.gz

Made-with: Cursor
2026-04-17 13:40:31 +00:00

140 lines
4 KiB
PHP

<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\Services\Util;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class BookingStorno
*
* @property int $id
* @property int $booking_id
* @property float $total
* @property float $storno
* @property Carbon $storno_date
* @property boolean $binary_data
* @property bool $done
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Booking $booking
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereBinaryData($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereBookingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereDone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereStorno($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereStornoDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereUpdatedAt($value)
* @property \Illuminate\Support\Carbon|null $storno_print
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereStornoPrint($value)
* @property-read \App\Models\BookingDocument|null $booking_document
* @mixin \Eloquent
*/
class BookingStorno extends Model
{
protected $table = 'booking_storno';
protected $casts = [
'booking_id' => 'int',
'total' => 'float',
'storno' => 'float',
'done' => 'bool',
'storno_date' => 'datetime',
'storno_print' => 'datetime',
];
protected $fillable = [
'booking_id',
'total',
'storno',
'storno_date',
'storno_print',
'binary_data',
'done'
];
public function booking()
{
return $this->belongsTo(Booking::class);
}
public function booking_document()
{
return $this->hasOne(BookingDocument::class, 'booking_storno_id', 'id');
}
public function getTotalFormatted()
{
return Util::_number_format($this->attributes['total']);
}
public function getTotalRaw()
{
return $this->attributes['total'];
}
public function setTotalAttribute($value)
{
$this->attributes['total'] = Util::_clean_float($value);
}
public function getStornoFormatted()
{
return Util::_number_format($this->attributes['storno']);
}
public function getStornoRaw()
{
return $this->attributes['storno'];
}
public function setStornoAttribute($value)
{
$this->attributes['storno'] = Util::_clean_float($value);
}
public function getStornoDateFormatted()
{
return isset($this->attributes['storno_date']) ? Carbon::parse($this->attributes['storno_date'])->format('d.m.Y') : '';
}
public function setStornoDateAttribute($value)
{
if (!$value) {
$this->attributes['storno_date'] = null;
} else {
$this->attributes['storno_date'] = Carbon::parse($value)->format('Y-m-d');
}
}
public function getStornoPrintFormatted()
{
return isset($this->attributes['storno_print']) ? Carbon::parse($this->attributes['storno_print'])->format('d.m.Y') : '';
}
public function setStornoPrintAttribute($value)
{
if (!$value) {
$this->attributes['storno_print'] = null;
} else {
$this->attributes['storno_print'] = Carbon::parse($value)->format('Y-m-d');
}
}
}