151 lines
4.8 KiB
PHP
151 lines
4.8 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 IQTravelItem
|
|
*
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property string $description
|
|
* @property string $highlights
|
|
* @property int $draft_type_id
|
|
* @property int $travel_country_id
|
|
* @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 TravelCountry $travel_country
|
|
* @property Collection|IQTravelGroupItem[] $i_q_travel_group_items
|
|
* @property Collection|IQTravelItemPlace[] $i_q_travel_item_places
|
|
* @package App\Models
|
|
* @property-read \App\Models\DraftType|null $draft_type
|
|
* @property-read int|null $i_q_travel_group_items_count
|
|
* @property-read int|null $i_q_travel_item_places_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereActive($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereDaysDuration($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereDaysStart($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereDescription($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereDraftTypeId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereHighlights($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereMinPersons($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem wherePos($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem wherePriceAdult($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem wherePriceChildren($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereTravelCountryId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQTravelItem whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class IQTravelItem extends Model
|
|
{
|
|
protected $connection = 'mysql_stern';
|
|
|
|
protected $table = 'i_q_travel_items';
|
|
|
|
protected $casts = [
|
|
'draft_type_id' => 'int',
|
|
'travel_country_id' => 'int',
|
|
'days_start' => 'int',
|
|
'days_duration' => 'int',
|
|
'min_persons' => 'int',
|
|
'price_adult' => 'float',
|
|
'price_children' => 'float',
|
|
'pos' => 'int',
|
|
'active' => 'bool'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'description',
|
|
'highlights',
|
|
'draft_type_id',
|
|
'travel_country_id',
|
|
'days_start',
|
|
'days_duration',
|
|
'min_persons',
|
|
'price_adult',
|
|
'price_children',
|
|
'pos',
|
|
'active'
|
|
];
|
|
|
|
public function travel_country()
|
|
{
|
|
return $this->belongsTo(TravelCountry::class);
|
|
}
|
|
|
|
public function i_q_travel_group_items()
|
|
{
|
|
return $this->hasMany(IQTravelGroupItem::class);
|
|
}
|
|
|
|
public function i_q_travel_item_places()
|
|
{
|
|
return $this->hasMany(IQTravelItemPlace::class)->orderBy('pos', 'ASC');
|
|
}
|
|
|
|
public function draft_type()
|
|
{
|
|
return $this->belongsTo(DraftType::class, 'draft_type_id');
|
|
}
|
|
|
|
|
|
|
|
//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;
|
|
}
|
|
}
|