351 lines
12 KiB
PHP
351 lines
12 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class TravelProgram
|
|
*
|
|
* @property int $id
|
|
* @property float|null $profit_margin
|
|
* @property int|null $category_id
|
|
* @property string|null $program_code
|
|
* @property int|null $program_duration
|
|
* @property bool|null $is_seasonal
|
|
* @property bool|null $youth
|
|
* @property string|null $title
|
|
* @property string|null $subtitle
|
|
* @property string|null $slider_info
|
|
* @property int|null $program_type
|
|
* @property int|null $organizer
|
|
* @property int|null $generalnote
|
|
* @property int|null $status
|
|
* @property string|null $included
|
|
* @property string|null $class_description
|
|
* @property string|null $excluded
|
|
* @property string|null $advices
|
|
* @property string|null $notes
|
|
* @property string|null $url
|
|
* @property int|null $max_age_for_children
|
|
* @property string|null $html_description
|
|
* @property int|null $insurance_1
|
|
* @property int|null $insurance_2
|
|
* @property int|null $insurance_3
|
|
* @property int|null $insurance_4
|
|
* @property bool $in_slider
|
|
* @property bool $show_map
|
|
* @property string|null $map_html
|
|
* @property string $map_image
|
|
* @property string $map_image_ext
|
|
* @property int|null $travel_country
|
|
* @property int|null $travel_category
|
|
* @property int|null $travel_agenda
|
|
* @property int|null $deposit_percent
|
|
* @property bool|null $netto_prices_in_euro
|
|
* @property string|null $text_right
|
|
* @property float|null $default_flight_price
|
|
* @property int|null $travel_arrival_point_id
|
|
* @property string|null $weekdays
|
|
* @property int|null $position
|
|
* @property float|null $discount
|
|
* @property int|null $discount_is_percent_value
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property TravelArrivalPoint|null $travel_arrival_point
|
|
* @property TravelOrganizer|null $travel_organizer
|
|
* @property TravelInsurance|null $travel_insurance
|
|
* @property TravelGeneralNote|null $travel_general_note
|
|
* @property Option $option
|
|
* @property Collection|TravelClass[] $travel_classes
|
|
* @property Collection|TravelDeparturePoint[] $travel_departure_points
|
|
* @property Collection|TravelPeriod[] $travel_periods
|
|
* @property TravelProgramCountry $travel_program_country
|
|
* @property TravelProgramDestination $travel_program_destination
|
|
* @property Collection|TravelProgramDraft[] $travel_program_drafts
|
|
* @property Collection|TravelProgramImage[] $travel_program_images
|
|
* @property TravelProgramOption $travel_program_option
|
|
* @property TravelProgramRelated $travel_program_related
|
|
* @package App\Models
|
|
* @property int|null $travel_company
|
|
* @property-read Collection|\App\Models\TravelClass[] $classes
|
|
* @property-read int|null $classes_count
|
|
* @property-read int|null $travel_classes_count
|
|
* @property-read int|null $travel_program_drafts_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereAdvices($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereCategoryId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereClassDescription($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereDefaultFlightPrice($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereDepositPercent($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereDiscount($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereDiscountIsPercentValue($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereExcluded($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereGeneralnote($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereHtmlDescription($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInSlider($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereIncluded($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInsurance1($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInsurance2($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInsurance3($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInsurance4($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereIsSeasonal($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereMapHtml($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereMapImage($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereMapImageExt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereMaxAgeForChildren($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereNettoPricesInEuro($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereNotes($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereOrganizer($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram wherePosition($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereProfitMargin($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereProgramCode($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereProgramDuration($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereProgramType($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereShowMap($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereSliderInfo($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereStatus($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereSubtitle($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTextRight($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTitle($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelAgenda($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelArrivalPointId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelCategory($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelCompany($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelCountry($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereUrl($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereWeekdays($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereYouth($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class TravelProgram extends Model
|
|
{
|
|
protected $connection = 'mysql_stern';
|
|
|
|
protected $table = 'travel_program';
|
|
|
|
protected $casts = [
|
|
'profit_margin' => 'float',
|
|
'category_id' => 'int',
|
|
'program_duration' => 'int',
|
|
'is_seasonal' => 'bool',
|
|
'youth' => 'bool',
|
|
'program_type' => 'int',
|
|
'organizer' => 'int',
|
|
'generalnote' => 'int',
|
|
'status' => 'int',
|
|
'max_age_for_children' => 'int',
|
|
'insurance_1' => 'int',
|
|
'insurance_2' => 'int',
|
|
'insurance_3' => 'int',
|
|
'insurance_4' => 'int',
|
|
'in_slider' => 'bool',
|
|
'show_map' => 'bool',
|
|
'travel_country' => 'int',
|
|
'travel_category' => 'int',
|
|
'travel_agenda' => 'int',
|
|
'travel_company' => 'int',
|
|
'deposit_percent' => 'int',
|
|
'netto_prices_in_euro' => 'bool',
|
|
'default_flight_price' => 'float',
|
|
'travel_arrival_point_id' => 'int',
|
|
'position' => 'int',
|
|
'discount' => 'float',
|
|
'discount_is_percent_value' => 'int'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'profit_margin',
|
|
'category_id',
|
|
'program_code',
|
|
'program_duration',
|
|
'is_seasonal',
|
|
'youth',
|
|
'title',
|
|
'subtitle',
|
|
'slider_info',
|
|
'program_type',
|
|
'organizer',
|
|
'generalnote',
|
|
'status',
|
|
'included',
|
|
'class_description',
|
|
'excluded',
|
|
'advices',
|
|
'notes',
|
|
'url',
|
|
'max_age_for_children',
|
|
'html_description',
|
|
'payment_conditions',
|
|
'insurance_1',
|
|
'insurance_2',
|
|
'insurance_3',
|
|
'insurance_4',
|
|
'in_slider',
|
|
'show_map',
|
|
'map_html',
|
|
'map_image',
|
|
'map_image_ext',
|
|
'travel_country',
|
|
'travel_category',
|
|
'travel_agenda',
|
|
'travel_company',
|
|
'deposit_percent',
|
|
'netto_prices_in_euro',
|
|
'text_right',
|
|
'default_flight_price',
|
|
'travel_arrival_point_id',
|
|
'weekdays',
|
|
'position',
|
|
'discount',
|
|
'discount_is_percent_value'
|
|
];
|
|
|
|
public static $programTypeTypes = [
|
|
0 => 'Eigenveranstaltung',
|
|
1 => 'Vermittlung'
|
|
];
|
|
|
|
public static $programDiscountTypes = [
|
|
0 => '€',
|
|
1 => '%'
|
|
];
|
|
|
|
|
|
public static $travelCategoryTypes = [
|
|
1 => 'Ägypten-Reise',
|
|
2 => 'Israel-Reise',
|
|
3 => 'Jordanien-Reise',
|
|
4 => 'Reise ohne Conversion-Code'
|
|
];
|
|
|
|
public function travel_arrival_point()
|
|
{
|
|
return $this->belongsTo(TravelArrivalPoint::class, 'travel_arrival_point_id');
|
|
}
|
|
//default 1 sterntours
|
|
public function travel_organizer()
|
|
{
|
|
return $this->belongsTo(TravelOrganizer::class, 'organizer');
|
|
}
|
|
|
|
public function travel_insurance()
|
|
{
|
|
return $this->belongsTo(TravelInsurance::class, 'insurance_3');
|
|
}
|
|
|
|
public function travel_program_category()
|
|
{
|
|
return $this->belongsTo(TravelProgramCategory::class, 'category_id');
|
|
}
|
|
|
|
public function travel_general_note()
|
|
{
|
|
return $this->belongsTo(TravelGeneralNote::class, 'generalnote');
|
|
}
|
|
|
|
public function option()
|
|
{
|
|
return $this->hasOne(Option::class, 'program_id');
|
|
}
|
|
|
|
public function page()
|
|
{
|
|
return $this->hasOne(Page::class, 'travel_program');
|
|
}
|
|
|
|
public function classes()
|
|
{
|
|
return $this->hasMany(TravelClass::class, 'program_id');
|
|
}
|
|
|
|
|
|
public function travel_classes()
|
|
{
|
|
return $this->hasMany(TravelClass::class, 'program_id');
|
|
}
|
|
|
|
public function travel_departure_points()
|
|
{
|
|
return $this->hasMany(TravelDeparturePoint::class, 'program_id');
|
|
}
|
|
|
|
public function travel_periods()
|
|
{
|
|
return $this->hasMany(TravelPeriod::class, 'program_id');
|
|
}
|
|
|
|
public function travel_program_country()
|
|
{
|
|
return $this->hasOne(TravelProgramCountry::class, 'program_id');
|
|
}
|
|
|
|
public function travel_program_destination()
|
|
{
|
|
return $this->hasOne(TravelProgramDestination::class, 'program_id');
|
|
}
|
|
|
|
public function travel_program_drafts()
|
|
{
|
|
return $this->hasMany(TravelProgramDraft::class);
|
|
}
|
|
|
|
public function travel_program_images()
|
|
{
|
|
return $this->hasMany(TravelProgramImage::class, 'program_id');
|
|
}
|
|
|
|
public function travel_program_option()
|
|
{
|
|
return $this->hasOne(TravelProgramOption::class, 'program_id');
|
|
}
|
|
|
|
public function travel_program_related()
|
|
{
|
|
return $this->hasOne(TravelProgramRelated::class, 'program_2');
|
|
}
|
|
|
|
public function hasTravelProgramDrafts (){
|
|
if($this->travel_program_drafts->count()){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public function getWeekdaysArray(){
|
|
if($this->weekdays){
|
|
return explode(',', $this->weekdays);
|
|
}
|
|
if($this->weekdays !== NULL){
|
|
return array(0);
|
|
}
|
|
return [];
|
|
}
|
|
|
|
public function setWeekdaysFromArray($value){
|
|
if($value){
|
|
if(is_array($value)){
|
|
if($value[0] === NULL){
|
|
$this->weekdays = "0,1,2,3,4,5,6";
|
|
}else{
|
|
$this->weekdays = implode(',', $value);
|
|
}
|
|
}else{
|
|
$this->weekdays = $value;
|
|
}
|
|
return $this->weekdays;
|
|
|
|
}
|
|
return "";
|
|
}
|
|
}
|