Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel search data relationship

$data = Subcategory::with(["category"])
                            ->where('name','like', '%'.$this->searchData.'%')
                            ->orWhereHas('category', function($query){$query->where('name', 'like', '%'.$this->searchData.'%');})
                            ->orderBy($this->orderByData, $this->orderByAsc ? 'asc' : 'desc')
                            ->paginate($this->showData);
 
PREVIOUS NEXT
Tagged: #laravel #search #data #relationship
ADD COMMENT
Topic
Name
1+8 =