mardi 16 avril 2019

Can I use a PHP (laravel) controller directly inside my VueJS view?

I added a searchbar with results with VueJS, and this works great with a simple query. Now, I would like to do the same but with more complex filters.

Here is my VueJS search component

<button class="btn btn-primary" @click="search" @keyup.enter="search" type="button">Search</button>

methods: {
            search() {
                axios.get('/races/find?q=%'+ this.query+'%').then(
                    response => {
                        this.races=response.data;
                    }
                );
            }
        }

in web.php

Route::get('/race/find', 'RacesController@searchRaces');

in RacesController

public function searchRaces(Request $request)
{
    return DB::connection('mysql1')->select(REQUEST);
}

This works great.

Now I will have some more complex filters, with dates, sliders, multiple data. So i can't pass it directly in my query, or I would have a super long request with 15 values... Is it possible to call directly my Laravel controller in my Vue view?

Thanks a lot in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire