mercredi 13 octobre 2021

create string route in script blade laravel

I´m traying to create function with function onClick(parameter) that call one function and redirect to one route in laravel, but my problem it´s that this route have 3 parameter.

Route::get('llamadas/estadisticas/pasadas/{operator}/{fromDate},{toDate}', 'EstadisticaLlamadaController@getStateCallCommercial')->name('llamadas.estadisticas.pasadas');

my function it´s:

function redirectFunction(operator)
    {
        let fromDate = $("#fromDate").val();
        let toDate = $("#toDate").val();
        
        var yearStart = fromDate.substring(0,4);
        var monthStart = fromDate.substring(5,7);
        var dayStart = fromDate.substring(8,10);

        var yearEnd = toDate.substring(0,4);
        var monthEnd = toDate.substring(5,7);
        var dayEnd = toDate.substring(8,10);

        fromDate = dayStart + "-" + monthStart + "-" + yearStart;
        toDate = dayEnd + "-" + monthEnd + "-" + yearEnd;

        var url = "";
        url = url.replace(':operator', operator);
        url = url.replace(':fromDate', fromDate);
        url = url.replace(':toDate', toDate);
        console.log(url);
        //window.location.href = url;
    }

i need set this parameter in my route. I´m using url because i can´t use route, always return that parameter it´s incorrect. I know that it´s better to use Route

i need create this route for send this data to my controller that execute query and return this results to blade to generate statistics with chart.js and i need all parameter. But i cant generate nothing if i don´t send good my data.

now i´m returning this:

http://localhost:5080/gdsRepository/public/admin.llamadas.estadisticas.pasadas/%3Aoperator/%3AfromDate/%3AtoDate

if i do:

var url = "";

return this:

http://localhost:5080/gdsRepository/public/admin.llamadas.estadisticas.pasadas/%22%2Boperator%2B%22/%22%2BfromDate%2B%22/%22%2BtoDate%2B%22

anybody can help me, please??

thanks for readme and help me



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2YIdSqH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire