laravel search data relationship

Solutions on MaxInterview for laravel search data relationship by the best coders in the world

showing results for - "laravel search data relationship"
Elijah
22 Sep 2017
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);