Level 3
@appyapp After calling the get() function on the query builder instance toSql() won't work so store the SQL in the variable before calling get method.
$products = Vacancy::statusId($request->query('status'))
->sellerId($request->query('seller'))
->categoryId($request->query('category'))
->locationId($selectedLocationId)
->get();
I can see in the debugbar on my local pc that a query is executed e.g. SELECT * FROM products WHERE status_id=2 AND seller_id=5 AND category_id=19;
How do I store this query in variable?
`$sql = $products->toSql(); (Obviously it throws error). What do I need to do here?
$builder = Vacancy::statusId($request->query('status'))
->sellerId($request->query('seller'))
->categoryId($request->query('category'))
->locationId($selectedLocationId);
$query = $builder->toSql();
$products = $builder->get();
Please or to participate in this conversation.