1$data = Subcategory::with(["category"])
2 ->where('name','like', '%'.$this->searchData.'%')
3 ->orWhereHas('category', function($query){$query->where('name', 'like', '%'.$this->searchData.'%');})
4 ->orderBy($this->orderByData, $this->orderByAsc ? 'asc' : 'desc')
5 ->paginate($this->showData);