mein-sterntours/app/Models/TravelPageGuide.php
2025-04-01 10:40:14 +02:00

166 lines
8.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\TravelPageGuide
*
* @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 $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 string $date
* @property int $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 \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereBoxBody($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereBoxDiscount($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereBoxImageUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereBoxStar($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereBumaDestination($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereBumaGjr($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereCanonicalUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereCatalogId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereCatalogIndex($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereCmsSettings($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereContent($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereContentNew($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereFewoLodging($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereKeyword($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereKeywords($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereLft($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereLvl($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereModel($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereOLDCatalogID($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereOLDOwnerID($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereOrder($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereOwner($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereOwnerSecond($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide wherePagetitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereParentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide wherePriceTags($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereRealUrlPath($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereRgt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereShowInNavi($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereTemplate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereTextRight($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereTravelGuideContentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereTravelProgram($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereTreeRoot($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereUpdatedAt($value)
* @property string|null $title_short
* @property string|null $before_title
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereBeforeTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelPageGuide whereTitleShort($value)
* @mixin \Eloquent
*/
class TravelPageGuide extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'page';
protected $fillable = [
'slug',
'status',
'show_in_navi',
'order',
'title',
'pagetitle',
'description',
'keywords',
'content_new',
'travel_guide_content_id',
];
private static $pages = [];
public static function getPageGuides($root_id = false){
if($root_id){
$values = self::where('tree_root', $root_id)->where('model', 'travel_guide')->where('lvl', 1)->orderBy('order')->get();
}else{
$values = self::where('model', 'travel_guide')->where('lvl', 1)->orderBy('order')->get();
}
foreach ($values as $value){
self::$pages[] = $value;
$value->checkChilds();
if($childs = $value->getChilds()){
foreach ($childs as $child){
$ret[] = $child;
}
}
}
return self::$pages;
}
public function checkChilds(){
if($childs = $this->getChilds()){
foreach ($childs as $child){
self::$pages[] = $child;
$child->checkChilds();
}
}
}
public function getChilds(){
return TravelPageGuide::where('parent_id', $this->id)->where('lvl', ($this->lvl+1))->orderBy('order')->get();
}
public function getContentNewAttribute()
{
return isset($this->attributes['content_new']) ? $this->attributes['content_new'] : $this->attributes['content'];
}
}