sortBy(fn ($a) => $a->deleted_at); }else{ return static::where('user_id',get_current_user_id()) ->where('deleted_at','0000-00-00 00:00:00') ->get(); } } public function canTrash(){ return current_user_can('wowpress_edit_complaints') || $this->user_id == get_current_user_id(); } public function trash(){ $this->deleted_at = date('Y-m-d H:i:s'); $this->save(); } public function restore(){ $this->deleted_at = null; $this->save(); } public function user(){ return $this->belongsTo(User::class); } public function canEdit(){ return current_user_can('wowpress_edit_complaints');# && (get_current_user_id() != $this->user_id); } }