141 lines
No EOL
5.9 KiB
PHP
141 lines
No EOL
5.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* App\Models\TravelCountry
|
|
*
|
|
* @property int $id
|
|
* @property int|null $crm_id
|
|
* @property string $name
|
|
* @property string|null $html_information
|
|
* @property string|null $entry_requirements
|
|
* @property int|null $feedback_page_id
|
|
* @property int|null $is_customer_country
|
|
* @property int|null $active_frontend
|
|
* @property int|null $active_backend
|
|
* @property string|null $updated_at
|
|
* @property string|null $created_at
|
|
* @property-read \App\Models\Page|null $feedback_page
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelNationalityRequirement[] $travel_nationality_requirements
|
|
* @property-read \App\Models\TravelProgramCountry $travel_program_country
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereActiveBackend($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereActiveFrontend($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereCrmId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereEntryRequirements($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereFeedbackPageId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereHtmlInformation($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereIsCustomerCountry($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry query()
|
|
* @property string|null $slug
|
|
* @property string|null $text_before
|
|
* @property string|null $text_after
|
|
* @property string|null $contact_headline
|
|
* @property string|null $contact_text_1
|
|
* @property string|null $contact_text_2
|
|
* @property string|null $contact_text_3
|
|
* @property string|null $contact_text_4
|
|
* @property string|null $contact_footer
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactFooter($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactHeadline($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactText1($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactText2($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactText3($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactText4($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereSlug($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereTextAfter($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereTextBefore($value)
|
|
* @property array|null $contact_lands
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactLands($value)
|
|
*/
|
|
class TravelCountry extends Model
|
|
{
|
|
//use the connection to sec. Datebase sterntours
|
|
protected $connection = 'mysql_stern';
|
|
|
|
protected $table = 'travel_country';
|
|
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'slug',
|
|
'html_information',
|
|
'text_before',
|
|
'text_after',
|
|
'contact_lands',
|
|
'contact_headline',
|
|
'contact_text_1',
|
|
'contact_text_2',
|
|
'contact_text_3',
|
|
'contact_text_4',
|
|
'contact_footer',
|
|
'entry_requirements',
|
|
'is_customer_country',
|
|
'active_frontend',
|
|
'active_backend'
|
|
|
|
];
|
|
|
|
protected $casts = ['contact_lands' => 'array'];
|
|
|
|
|
|
public $timestamps = false;
|
|
|
|
public function travel_program_country()
|
|
{
|
|
return $this->hasOne('App\Models\TravelProgramCountry', 'country_id', 'id');
|
|
}
|
|
|
|
public function feedback_page()
|
|
{
|
|
return $this->belongsTo('App\Models\Page', 'feedback_page_id', 'id');
|
|
}
|
|
|
|
public function travel_nationality_requirements()
|
|
{
|
|
return $this->hasMany('App\Models\TravelNationalityRequirement', 'travel_country_id', 'id');
|
|
}
|
|
|
|
public function setSlugAttribute( $value ) {
|
|
if(!isset($value) || $value == ""){
|
|
$this->attributes['slug'] = Str::slug(pre_slug($this->name), '-');
|
|
}else{
|
|
$this->attributes['slug'] = Str::slug(pre_slug($value), '-');
|
|
}
|
|
}
|
|
|
|
public function getNationalityRequirement($travel_nationality_id){
|
|
|
|
$model = TravelNationalityRequirement::where('travel_country_id', $this->id)->where('travel_nationality_id', $travel_nationality_id)->first();
|
|
if($model){
|
|
return $model->text;
|
|
}
|
|
return "";
|
|
}
|
|
|
|
public function setNationalityRequirement($travel_nationality_id, $text){
|
|
$model = TravelNationalityRequirement::where('travel_country_id', $this->id)->where('travel_nationality_id', $travel_nationality_id)->first();
|
|
if($model){
|
|
$model->text = $text;
|
|
$model->save();
|
|
}else{
|
|
$data = [
|
|
'travel_country_id' => $this->id,
|
|
'travel_nationality_id' => $travel_nationality_id,
|
|
'text' => $text,
|
|
];
|
|
TravelNationalityRequirement::create($data);
|
|
}
|
|
return "";
|
|
}
|
|
} |