mein-sterntours/app/Models/IQTravelGroup.php
2021-08-06 15:28:57 +02:00

107 lines
2.5 KiB
PHP

<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
/**
* Class IQTravelGroup
*
* @property int $id
* @property string $name
* @property string $description
* @property string $highlights
* @property int $days_start
* @property int $days_duration
* @property int $min_persons
* @property float $price_adult
* @property float $price_children
* @property int $pos
* @property bool $active
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property Collection|IQTravelGroupItem[] $i_q_travel_group_items
*
* @package App\Models
*/
class IQTravelGroup extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'i_q_travel_groups';
protected $casts = [
'days_start' => 'int',
'days_duration' => 'int',
'min_persons' => 'int',
'price_adult' => 'float',
'price_children' => 'float',
'pos' => 'int',
'active' => 'bool'
];
protected $fillable = [
'name',
'description',
'highlights',
'days_start',
'days_duration',
'min_persons',
'price_adult',
'price_children',
'pos',
'active'
];
public function i_q_travel_group_items()
{
return $this->hasMany(IQTravelGroupItem::class)->orderBy('pos', 'DESC');
}
//price_adult
public function getPriceAdultAttribute()
{
return isset($this->attributes['price_adult']) ? Util::_number_format($this->attributes['price_adult']) : null;
}
public function setPriceAdultAttribute($value)
{
$this->attributes['price_adult'] = $value ? Util::_clean_float($value) : null;
}
public function getPriceAdultRaw()
{
return isset($this->attributes['price_adult']) ? $this->attributes['price_adult'] : 0;
}
public function setPriceAdultRaw($value)
{
return $this->attributes['price_adult'] = $value;
}
//price_children
public function getPriceChildrenAttribute()
{
return isset($this->attributes['price_children']) ? Util::_number_format($this->attributes['price_children']) : null;
}
public function setPriceChildrenAttribute($value)
{
$this->attributes['price_children'] = $value ? Util::_clean_float($value) : null;
}
public function getPriceChildrenRaw()
{
return isset($this->attributes['price_children']) ? $this->attributes['price_children'] : 0;
}
public function setPriceChildrenRaw($value)
{
return $this->attributes['price_children'] = $value;
}
}