mein-sterntours/app/Models/Page.php
2023-07-03 10:10:09 +02:00

218 lines
4.6 KiB
PHP

<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class Page
*
* @property int $id
* @property int|null $owner
* @property string|null $model
* @property int|null $lvl
* @property int $owner_second
* @property int|null $catalog_id
* @property int|null $catalog_index
* @property string|null $slug
* @property int|null $travel_program
* @property int|null $status
* @property int|null $show_in_navi
* @property int|null $order
* @property string|null $title
* @property string|null $title_short
* @property string|null $before_title
* @property string|null $pagetitle
* @property string|null $description
* @property string|null $keywords
* @property string|null $content
* @property string|null $content_new
* @property string|null $buma_destination
* @property int|null $OLD_CatalogID
* @property int|null $OLD_OwnerID
* @property int|null $buma_gjr
* @property Carbon $date
* @property bool $price-tags
* @property string|null $text_right
* @property string|null $keyword
* @property string|null $canonical_url
* @property int|null $country_id
* @property string|null $template
* @property int|null $lft
* @property int|null $rgt
* @property int|null $tree_root
* @property int|null $parent_id
* @property string|null $real_url_path
* @property int|null $travel_guide_content_id
* @property string|null $box_body
* @property string|null $box_image_url
* @property string|null $box_star
* @property string|null $box_discount
* @property string|null $cms_settings
* @property int|null $fewo_lodging
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @property Page|null $page
* @property TravelCountry|null $travel_country
* @property TravelGuide|null $travel_guide
* @property Collection|Page[] $pages
* @property Collection|Redirect[] $redirects
* @property Collection|TravelCountry[] $travel_countries
* @property Collection|TravelProgram[] $travel_program_content
*
* @package App\Models
*/
class Page extends Model
{
use Sluggable;
protected $connection = 'mysql_stern';
protected $table = 'page';
protected $casts = [
'owner' => 'int',
'lvl' => 'int',
'owner_second' => 'int',
'catalog_id' => 'int',
'catalog_index' => 'int',
'travel_program' => 'int',
'status' => 'int',
'show_in_navi' => 'int',
'order' => 'int',
'OLD_CatalogID' => 'int',
'OLD_OwnerID' => 'int',
'buma_gjr' => 'int',
'price-tags' => 'bool',
'country_id' => 'int',
'lft' => 'int',
'rgt' => 'int',
'tree_root' => 'int',
'parent_id' => 'int',
'travel_guide_content_id' => 'int',
'fewo_lodging' => 'int'
];
protected $dates = [
'date'
];
protected $fillable = [
'owner',
'model',
'lvl',
'owner_second',
'catalog_id',
'catalog_index',
'slug',
'travel_program',
'status',
'show_in_navi',
'order',
'title',
'title_short',
'before_title',
'pagetitle',
'description',
'keywords',
'content',
'content_new',
'buma_destination',
'OLD_CatalogID',
'OLD_OwnerID',
'buma_gjr',
'date',
'price-tags',
'text_right',
'keyword',
'canonical_url',
'country_id',
'template',
'lft',
'rgt',
'tree_root',
'parent_id',
'real_url_path',
'travel_guide_content_id',
'box_body',
'box_image_url',
'box_star',
'box_discount',
'cms_settings',
'fewo_lodging'
];
public function sluggable()
{
return [
'slug' => [
'source' => 'title'
]
];
}
public function page()
{
return $this->belongsTo(Page::class, 'tree_root');
}
public function fewo_lodging()
{
return $this->belongsTo(FewoLodging::class, 'fewo_lodging');
}
public function travel_country()
{
return $this->belongsTo(TravelCountry::class, 'country_id');
}
public function travel_guide()
{
return $this->belongsTo(TravelGuide::class, 'travel_guide_content_id');
}
public function pages()
{
return $this->hasMany(Page::class, 'tree_root');
}
public function redirects()
{
return $this->hasMany(Redirect::class);
}
public function travel_countries()
{
return $this->hasMany(TravelCountry::class, 'feedback_page_id');
}
public function child_pages()
{
return $this->hasMany(Page::class, 'owner');
}
public function parent_page()
{
return $this->belongsTo(Page::class, 'parent_id');
}
public function travel_program_content()
{
return $this->belongsTo(TravelProgram::class, 'travel_program');
}
public function getContentNew()
{
return $this->content_new ? $this->content_new : $this->content;
}
}