mercredi 4 novembre 2015

Laravel 5: How to run same query when click to pagination links

I am creating a dynamic query depending on user's form selections and diplaying the query result as paginated.

            $query = 'v.id';

            if($model == 1){
                $query .= ' ,v.model';
            }

            if($marka == 1){
                $query .= ' ,v.brand_name';
            }

            if($plaka == 1){
                $query .= ' ,v.licenseplate';
            }

            if($fiyat == 1){
                $query .= ' ,v.buying_price';
            }
            .
            .      
            .


            $query_result = DB::table('vehicles AS v')   
            ->selectRaw($query)
            ->paginate(25);

The problem is, once i click to pagination links page is refreshing and dynamic query backs to its initial value so most of the data gets missed. I tried to use appends() but couldnt find a proper solution so far. Any help would be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire