142 lines
4 KiB
PHP
142 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'
|
|
];
|
|
|
|
protected $dates = [
|
|
'storno_date',
|
|
'storno_print'
|
|
];
|
|
|
|
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');
|
|
}
|
|
}
|
|
|
|
|
|
}
|