mein-sterntours/app/Models/DraftItem.php
2025-04-01 10:40:14 +02:00

125 lines
4.7 KiB
PHP

<?php
namespace App\Models;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\DraftItem
*
* @property int $id
* @property int $draft_id
* @property int $draft_type_id
* @property int|null $days_start
* @property int|null $days_duration
* @property string|null $name
* @property float|null $price_adult
* @property int|null $adult
* @property float|null $price_children
* @property int|null $children
* @property string|null $content
* @property int|null $pos
* @property int $in_pdf
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Draft $draft
* @property-read \App\Models\DraftType $draft_type
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereAdult($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereChildren($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereContent($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereDaysDuration($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereDaysStart($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereDraftId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereDraftTypeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereInPdf($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem wherePriceAdult($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem wherePriceChildren($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereUpdatedAt($value)
* @property string|null $service
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereService($value)
* @property float|null $price
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem query()
* @mixin \Eloquent
*/
class DraftItem extends Model
{
protected $connection = 'mysql';
protected $table = 'draft_items';
protected $fillable = [
'pos'
];
public function draft()
{
return $this->belongsTo('App\Models\Draft', 'draft_id');
}
public function draft_type()
{
return $this->belongsTo('App\Models\DraftType', 'draft_type_id');
}
public function setPriceAdultAttribute($value)
{
$this->attributes['price_adult'] = Util::_clean_float($value);
}
public function getPriceAdultAttribute()
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['price_adult']), 2, ',', '.');
}
public function getPriceAdultRaw()
{
return isset($this->attributes['price_adult']) ? $this->attributes['price_adult'] : 0;
}
public function setPriceChildrenAttribute($value)
{
$this->attributes['price_children'] = Util::_clean_float($value);
}
public function getPriceChildrenAttribute()
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['price_children']), 2, ',', '.');
}
public function getPriceChildrenRaw()
{
return isset($this->attributes['price_children']) ? $this->attributes['price_children'] : 0;
}
public function setPriceAttribute($value)
{
$this->attributes['price'] = Util::_clean_float($value);
}
public function getPriceAttribute()
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['price']), 2, ',', '.');
}
public function getPriceRaw()
{
return isset($this->attributes['price']) ? $this->attributes['price'] : 0;
}
}