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
157 lines
5 KiB
PHP
157 lines
5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\Util;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class ServiceProviderEntry
|
|
*
|
|
* @property int $id
|
|
* @property int $booking_id
|
|
* @property int $service_provider_id
|
|
* @property float $amount
|
|
* @property float $amount_eur
|
|
* @property float $factor
|
|
* @property Carbon $payment_date
|
|
* @property string $invoice_number
|
|
* @property bool $is_cleared
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
* @property string $type
|
|
* @property Booking $booking
|
|
* @property ServiceProvider $service_provider
|
|
* @package App\Models
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereAmount($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereAmountEur($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereBookingId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereFactor($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereInvoiceNumber($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereIsCleared($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry wherePaymentDate($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereServiceProviderId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereType($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderEntry whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class ServiceProviderEntry extends Model
|
|
{
|
|
protected $table = 'service_provider_entry';
|
|
|
|
protected $casts = [
|
|
'booking_id' => 'int',
|
|
'service_provider_id' => 'int',
|
|
'amount' => 'float',
|
|
'amount_eur' => 'float',
|
|
'factor' => 'float',
|
|
'is_cleared' => 'bool',
|
|
'payment_date' => 'datetime',
|
|
];
|
|
|
|
|
|
protected $fillable = [
|
|
'booking_id',
|
|
'service_provider_id',
|
|
'amount',
|
|
'amount_eur',
|
|
'factor',
|
|
'payment_date',
|
|
'invoice_number',
|
|
'is_cleared',
|
|
'type'
|
|
];
|
|
|
|
private static $counter = 0;
|
|
private static $bookingIds = array();
|
|
|
|
public function booking()
|
|
{
|
|
return $this->belongsTo(Booking::class);
|
|
}
|
|
|
|
public function service_provider()
|
|
{
|
|
return $this->belongsTo(ServiceProvider::class);
|
|
}
|
|
|
|
public function getCounter(){
|
|
if ($this->booking_id) {
|
|
if (!in_array($this->booking_id, self::$bookingIds)) {
|
|
self::$bookingIds[] = $this->booking_id;
|
|
self::$counter++;
|
|
}
|
|
return self::$counter;
|
|
}
|
|
}
|
|
|
|
public function setFactorAttribute($value)
|
|
{
|
|
$this->attributes['factor'] = floatval(preg_replace("/[^0-9.-]/", "", str_replace(',', '.', $value)));
|
|
}
|
|
public function getFactorAttribute()
|
|
{
|
|
return Util::_number_format($this->attributes['factor'], 4);
|
|
}
|
|
public function getFactortRaw()
|
|
{
|
|
return $this->attributes['factor'];
|
|
}
|
|
|
|
public function setAmountAttribute($value)
|
|
{
|
|
$this->attributes['amount'] = Util::_clean_float($value);
|
|
}
|
|
public function getAmountAttribute()
|
|
{
|
|
return Util::_number_format($this->attributes['amount']);
|
|
}
|
|
public function getAmountRaw()
|
|
{
|
|
return $this->attributes['amount'];
|
|
}
|
|
public function setAmountEurAttribute($value)
|
|
{
|
|
$this->attributes['amount_eur'] = Util::_clean_float($value);
|
|
}
|
|
public function getAmountEurAttribute()
|
|
{
|
|
return Util::_number_format($this->attributes['amount_eur']);
|
|
}
|
|
public function getAmountEurRaw()
|
|
{
|
|
return $this->attributes['amount_eur'];
|
|
}
|
|
|
|
|
|
public function getAmountFinalEur(){
|
|
$ret = $this->attributes['amount'];
|
|
if($this->attributes['amount_eur'] && $this->attributes['amount_eur'] > 0){
|
|
$ret = $this->attributes['amount_eur'];
|
|
}
|
|
return number_format($ret, 2, ',', '.');
|
|
}
|
|
|
|
public function getAmountFinalEurRaw(){
|
|
if($this->attributes['amount_eur'] && $this->attributes['amount_eur'] > 0){
|
|
return $this->attributes['amount_eur'];
|
|
}
|
|
return $this->attributes['amount'];
|
|
}
|
|
|
|
public function getPaymentDateFormat(){
|
|
if(!$this->attributes['payment_date']){ return ""; }
|
|
return Carbon::parse($this->attributes['payment_date'])->format(\Util::formatDateDB());
|
|
}
|
|
|
|
}
|