mercredi 24 février 2016

Laravel: don't execute query on page load

I'm building a filtersystem for my company's page much like webshops so you can get easily to an company. The below query that i've wrote is executing on page load..

What I want is load the page and all the results show up (not filtered) . When you select some filters and submit, then the results that match the filters value's show up.

$companys = Company::wherehas('reviews', function($query) use($Rstars){
            $query->where('stars', '=', $Rstars);
        })->orderBy('created_at', $request->cdate)->paginate(15);

I was thinking on submit that the user goes to another page with the filtered results, but I think thats not a good fix for this.

The other solution that I had was the if statement, but honestly I think thats creates a mess in the code.

Maybe it's a easy thing, but I can't find out how.

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire