123 lines
3.9 KiB
PHP
123 lines
3.9 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
|
|
* @property-read int|null $i_q_travel_group_items_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereActive($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereDaysDuration($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereDaysStart($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereDescription($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereHighlights($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereMinPersons($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup wherePos($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup wherePriceAdult($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup wherePriceChildren($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelGroup whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
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', 'ASC');
|
|
}
|
|
|
|
|
|
//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;
|
|
}
|
|
}
|