yajra / laravel-datatables

jQuery DataTables API for Laravel
https://yajrabox.com/docs/laravel-datatables
MIT License
4.75k stars 861 forks source link

Adding where condition in query method is not returning the correct data #3148

Closed jonjieviduya closed 4 months ago

jonjieviduya commented 4 months ago

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');
}