jeudi 8 mars 2018

How to declare variable in javascript code that is declared in another file?

So I am using Laravel 5.5, PHP 7.0

I have this at the bottom of my views file:

$("#myRange").ionRangeSlider({
    type: "double",
    grid: true,
    min: ,
    max: ,
    @if(isset($returnData['Ranges']) && count($returnData['Ranges']) > 0)
        from: ,
        to: 
    @else
        from: ,
        to: 
    @endif
});

The error is that $minPrice and $maxPrice are undeclared. BUT they are declared in my controllers file.

Here's the code in my controller file:

    $fees = array_unique($fees);
    $priceRanges = array();
    $minPrice = 0;
    $maxPrice = 0;
    if(count($fees) > 0){
        foreach ($fees as $key => $value) {
            $range = explode(' - ', $value);
            $priceRanges[] = $range['0'];
            $priceRanges[] = $range['1'];
        }
        $priceRanges = array_unique($priceRanges);
        $minPrice = (int) min($priceRanges);
        $maxPrice = (int) max($priceRanges);
    }

Anybody how how can I fix the javascript code in my views (front-end) file to declare the variable? I get this error on one specific page only which shows a list of items in my database. If I search for an item from the homepage and then see the search results page, there's no error. Only on the listings page.



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

Aucun commentaire:

Enregistrer un commentaire