228 lines
10 KiB
PHP
228 lines
10 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use HTMLHelper;
|
|
|
|
/**
|
|
* App\Models\Feedback
|
|
*
|
|
* @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|null $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 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
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Feedback[] $children
|
|
* @property-read \App\Models\Feedback|null $parent
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereBoxBody($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereBoxDiscount($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereBoxImageUrl($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereBoxStar($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereBumaDestination($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereBumaGjr($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereCanonicalUrl($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereCatalogId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereCatalogIndex($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereCmsSettings($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereContent($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereContentNew($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereCountryId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereDate($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereDescription($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereFewoLodging($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereKeyword($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereKeywords($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereLft($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereLvl($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereModel($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereOLDCatalogID($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereOLDOwnerID($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereOrder($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereOwner($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereOwnerSecond($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback wherePagetitle($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereParentId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback wherePriceTags($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereRealUrlPath($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereRgt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereShowInNavi($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereSlug($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereStatus($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereTemplate($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereTextRight($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereTitle($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereTravelProgram($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereTreeRoot($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereUpdatedAt($value)
|
|
* @property int|null $travel_guide_content_id
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereTravelGuideContentId($value)
|
|
* @property string|null $title_short
|
|
* @property string|null $before_title
|
|
* @property-read int|null $children_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereBeforeTitle($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Feedback whereTitleShort($value)
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Page> $child_pages
|
|
* @property-read int|null $child_pages_count
|
|
* @property-read \App\Models\Page|null $page
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Page> $pages
|
|
* @property-read int|null $pages_count
|
|
* @property-read \App\Models\Page|null $parent_page
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TravelCountry> $travel_countries
|
|
* @property-read int|null $travel_countries_count
|
|
* @property-read \App\Models\TravelCountry|null $travel_country
|
|
* @property-read \App\Models\TravelGuide|null $travel_guide
|
|
* @property-read \App\Models\TravelProgram|null $travel_program_content
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Page findSimilarSlugs(string $attribute, array $config, string $slug)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Page withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class Feedback extends Page
|
|
{
|
|
protected $table = 'page';
|
|
|
|
protected $fillable = [
|
|
'title', 'status', 'slug', 'date', 'content', 'content_new', 'box_body', 'description', 'pagetitle', 'keywords', 'order', 'active',
|
|
];
|
|
|
|
protected $casts = ['box_body' => 'array', 'date' => 'date', 'status' => 'boolean', 'active' => 'boolean'];
|
|
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::addGlobalScope(function ($query) {
|
|
$query->where('model', 'feedback');
|
|
$query->orderBy('lvl', 'ASC');
|
|
$query->orderBy('date', 'DESC');
|
|
|
|
});
|
|
}
|
|
|
|
public function parent()
|
|
{
|
|
return $this->belongsTo('App\Models\Feedback', 'parent_id');
|
|
}
|
|
|
|
public function getParent()
|
|
{
|
|
if ($this->lvl == 2) {
|
|
$this->parent();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function children()
|
|
{
|
|
return $this->hasMany('App\Models\Feedback', 'parent_id');
|
|
}
|
|
|
|
|
|
public function setContentAttribute($value)
|
|
{
|
|
if (!$value) {
|
|
$this->attributes['content'] = $value;
|
|
} else {
|
|
$this->attributes['content'] = HTMLHelper::filterHTML($value, ['src' => ['removeHost']], true);
|
|
}
|
|
}
|
|
|
|
public function getContentAttribute()
|
|
{
|
|
return $this->attributes['content_new'] === null ? $this->attributes['content'] : $this->attributes['content_new'];
|
|
}
|
|
|
|
public function setContentNewAttribute($value)
|
|
{
|
|
if (!$value) {
|
|
$this->attributes['content_new'] = $value;
|
|
} else {
|
|
$this->attributes['content_new'] = HTMLHelper::filterHTML($value, ['src' => ['removeHost']], true);
|
|
}
|
|
}
|
|
|
|
public function getContentNewAttribute()
|
|
{
|
|
return $this->attributes['content_new'] === null ? $this->attributes['content'] : $this->attributes['content_new'];
|
|
}
|
|
|
|
|
|
public function getParentsArray(){
|
|
//lvl 0
|
|
return Page::where('model', 'feedback')->where('lvl', 1)->get()->pluck('title', 'id');
|
|
|
|
}
|
|
//$feedbacks = Feedback::where('lvl', 1)->get();
|
|
public function getDateRow()
|
|
{
|
|
return$this->attributes['date'];
|
|
}
|
|
|
|
public function getDateAttribute()
|
|
{
|
|
return isset($this->attributes['date']) ? Carbon::parse($this->attributes['date'])->format("d.m.Y") : '';
|
|
}
|
|
|
|
public function setDateAttribute($value)
|
|
{
|
|
if (!$value) {
|
|
$this->attributes['date'] = null;
|
|
} else {
|
|
try {
|
|
$this->attributes['date']= Carbon::parse($value);
|
|
} catch (\Exception $e) {
|
|
$this->attributes['date'] = Carbon::now();
|
|
}
|
|
}
|
|
}
|
|
|
|
public function getImage($key){
|
|
//use box_body for images
|
|
if(isset($this->box_body[$key])){
|
|
return $this->box_body[$key];
|
|
}
|
|
return "";
|
|
}
|
|
}
|