Travel Group / Programms
This commit is contained in:
parent
9baa1a6233
commit
a718baf971
23 changed files with 808 additions and 89 deletions
159
app/Models/IQTravelProgram.php
Normal file
159
app/Models/IQTravelProgram.php
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
<?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 IQTravelProgram
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $code
|
||||
* @property int $travel_country_id
|
||||
* @property string $description
|
||||
* @property string $highlights
|
||||
* @property string $not_included
|
||||
* @property string $weekdays
|
||||
* @property int $days_duration
|
||||
* @property float $discount
|
||||
* @property float $deposit_pro
|
||||
* @property float $price_adult_total
|
||||
* @property float $price_children_total
|
||||
* @property string $travel_insurance
|
||||
* @property bool $active
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @property TravelCountry $travel_country
|
||||
* @property Collection|IQTravelProgramItem[] $i_q_travel_program_items
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class IQTravelProgram extends Model
|
||||
{
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'i_q_travel_programs';
|
||||
|
||||
protected $casts = [
|
||||
'travel_country_id' => 'int',
|
||||
'days_duration' => 'int',
|
||||
'typ' => 'int',
|
||||
'discount' => 'float',
|
||||
'deposit_pro' => 'float',
|
||||
'price_adult_total' => 'float',
|
||||
'price_children_total' => 'float',
|
||||
'active' => 'bool',
|
||||
'weekdays' => 'array',
|
||||
'travel_insurance' => 'array',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'code',
|
||||
'typ',
|
||||
'travel_country_id',
|
||||
'description',
|
||||
'highlights',
|
||||
'not_included',
|
||||
'weekdays',
|
||||
'days_duration',
|
||||
'discount',
|
||||
'deposit_pro',
|
||||
'price_adult_total',
|
||||
'price_children_total',
|
||||
'travel_insurance',
|
||||
'active'
|
||||
];
|
||||
|
||||
public static $status_type = [
|
||||
0 => '-',
|
||||
4 => '--- ist noch genau zu definieren',
|
||||
1 => 'individuelles Angebot',
|
||||
2 => 'Reiseangebot',
|
||||
3 => 'Reisekonfigurator',
|
||||
|
||||
];
|
||||
|
||||
public static $days = [
|
||||
0 => 'Sonntag',
|
||||
1 => 'Montag',
|
||||
2 => 'Dienstag',
|
||||
3 => 'Mittwoch',
|
||||
4 => 'Donnerstag',
|
||||
5 => 'Freitag',
|
||||
6 => 'Samstag'
|
||||
];
|
||||
|
||||
public function travel_country()
|
||||
{
|
||||
return $this->belongsTo(TravelCountry::class);
|
||||
}
|
||||
|
||||
public function i_q_travel_program_items()
|
||||
{
|
||||
return $this->hasMany(IQTravelProgramItem::class)->orderBy('pos', 'ASC');
|
||||
}
|
||||
|
||||
|
||||
//price_adult_total
|
||||
public function getPriceAdultTotalAttribute()
|
||||
{
|
||||
return isset($this->attributes['price_adult_total']) ? Util::_number_format($this->attributes['price_adult_total']) : null;
|
||||
}
|
||||
public function setPriceAdultTotalAttribute($value)
|
||||
{
|
||||
$this->attributes['price_adult_total'] = $value ? Util::_clean_float($value) : null;
|
||||
}
|
||||
public function getPriceAdultTotalRaw()
|
||||
{
|
||||
|
||||
return isset($this->attributes['price_adult_total']) ? $this->attributes['price_adult_total'] : 0;
|
||||
}
|
||||
public function setPriceAdultTotalRaw($value)
|
||||
{
|
||||
return $this->attributes['price_adult_total'] = $value;
|
||||
}
|
||||
|
||||
|
||||
//price_children_total
|
||||
public function getPriceChildrenTotalAttribute()
|
||||
{
|
||||
return isset($this->attributes['price_children_total']) ? Util::_number_format($this->attributes['price_children_total']) : null;
|
||||
}
|
||||
public function setPriceChildrenTotalAttribute($value)
|
||||
{
|
||||
$this->attributes['price_children_total'] = $value ? Util::_clean_float($value) : null;
|
||||
}
|
||||
public function getPriceChildrenTotalRaw()
|
||||
{
|
||||
return isset($this->attributes['price_children_total']) ? $this->attributes['price_children_total'] : 0;
|
||||
}
|
||||
public function setPriceChildrenTotalRaw($value)
|
||||
{
|
||||
return $this->attributes['price_children_total'] = $value;
|
||||
}
|
||||
|
||||
|
||||
public static function getWeekdaysOptions($weekdays = []){
|
||||
|
||||
if($weekdays === null){
|
||||
$weekdays = [];
|
||||
}
|
||||
$options = range(0, 6);
|
||||
$ret = '';
|
||||
foreach ($options as $option){
|
||||
$attr = (in_array($option, $weekdays)) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$option.'" '.$attr.'>'.(isset(self::$days[$option]) ? self::$days[$option] : '').'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue