I’m trying to add where
condition inside the query()
method, but it is not working as expected. Please see my code below.
Basically, the ->where('parent_id', 0)
is the one that I want to add, however, for some reason, it still returns all the data.
public function query(ProductCategory $model)
{
return $model->newQuery()
->select(['id', 'parent_id', 'name', 'slug', 'enabled'])
->where('parent_id', 0)
->orderBy('id', 'desc');
}
P.S. I’m using laravel 8