$child_pages * @property-read int|null $child_pages_count * @property-read \App\Models\Page|null $page * @property-read \Illuminate\Database\Eloquent\Collection $pages * @property-read int|null $pages_count * @property-read \App\Models\Page|null $parent_page * @property-read \Illuminate\Database\Eloquent\Collection $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 ""; } }