1

im using YajraBox for Datatables, it is Laravel extension.

I want to make it work with my Query String Filtering, so idea is tah i need to pass search request to ajax request

This is part of my form imput:

http://127.0.0.1:8000/lots?make%5B%5D=TOYOTA

So result have to be: only lots made by TOYOTA

This is my script for datatables with YajraBox:

<script type="text/javascript">
        $(document).ready(function(){
            $('#table').DataTable({
                bInfo: false,
                searching: false,
                processing: true,
                serverSide: true,
                ajax: '{{  url("/data") }}',
                columns: [
                    { data: 'date', name: 'date' },
                    { data: 'bid', name: 'bid' },
                    { data: 'auction_name', name: 'auction_name' },
                    { data: 'pics_urls', name: 'pics_urls' },
                    { data: 'company', name: 'company' },
                    { data: 'model_name_en', name: 'model_name_en' },
                    { data: 'model_type_en', name: 'model_type_en' },
                    { data: 'grade_en', name: 'grade_en' },
                    { data: 'mileage_en', name: 'mileage_en' },
                    { data: 'model_year_en', name: 'model_year_en' },
                    { data: 'color_en', name: 'color_en' },
                    { data: 'displacement', name: 'displacement' },
                    { data: 'transmission_en', name: 'transmission_en' },
                    { data: 'scores_en', name: 'scores_en' },
                    { data: 'start_price_en', name: 'start_price_en' },
                    { data: 'result_en', name: 'result_en' }
                ]
            });
        });
    </script>

This is my controllers for view and for ajax:

public function index()
    {
        return view('lots.browse');
    }

    public function indexData(LotFilters $filters)
    {
       $lots  = Lot::filter($filters);

        return Datatables::eloquent($lots)->make(true);
    } 

So what i think, i need to pass some howe ?make%5B%5D=TOYOTA to ajax request ajax: '{{ url("/data") }}',, any one know how to do it?

1 Answer 1

1

You can do this like:

"{{ url('/data') }}" + "?make="+value  // where value contains TOYOTA in it

and get this value in controller like:

Input::get('make');
Sign up to request clarification or add additional context in comments.

6 Comments

Wow, can you show me how i can put input? Do i have to use this facades: use Illuminate\Support\Facades\Input; ?
For using Input, you have to use Illuminate\Support\Facades\Input;. I just forget to mention this in the answser
Can you please show me how the controller will look? Sorry for it. Im newbie. I try like this: $lots = Lot::filter($filters)->withInput(Input::all()); but it didn't work
i figure it out !! Thank you!!
@DmitryMalys a little bit busy, good to know that you have solve it :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.