Ad

October CMS Overriding List Query

- 1 answer

In backend I have a list of records. And this list displays all records of this type. It is possible to override this query?

In controller I have Eloquent query and i grab some data from database, and i set this data in $query_data variable. Howe push this data in list view?

Ad

Answer

unfortunately, I didn't get exactly your point of telling override query, if you mean that set some condition in fetching data from database in Eloquent you have to use where for example in the example below we have users which their gender is male:

$users=User::where('gender','male')->get(); 

for set more condition you can do like this:

$users=User::where([['gender','male'],['status',1]])->get(); 

and for showing the variable in your view you can use compact method:

return view('YOUR BLADE FILE NAME',compact('users'));

hope be helpful bro

Ad
source: stackoverflow.com
Ad