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 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 { $this->attributes['date'] = (new Carbon($value))->format('Y-m-d'); } } }