mardi 20 octobre 2015

Server writing out javascript object as string instead of integer

I have a weird problem which I can't solve right now.

My local site (homestead) is writing out javascript objects in the page like so

var carriageCosts = [{"id":1,"weight":0,"cost":12,"created_at":"2015-10-20 06:25:13","updated_at":"2015-10-20 06:25:13"}]

Weight and cost are integers. After deploying to digitalocean using forge it is being written out like so

var carriageCosts = [{"id":"1","weight":"0","cost":"12","created_at":"2015-10-21 02:49:37","updated_at":"2015-10-21 02:49:37"}]

Weight and cost are now strings!!

This is causing errors with the javascript. Has anyone seen this before? Some direction in solving this would be greatly appreciated.

Data is sent to blade view like so

return view('quote.create')
    ->with([
        'customers' => $customers,
        'sellPrices' => \App\SellPrice::all(),
        'coreCaps' => \App\CoreCap::where('available', 1)->get(),
        'threePhaseCostings' => \App\ThreePhaseCosting::all()->first()
    ]);

Blade view writes out the data

var carriageCosts = {!! $carriageCosts !!};

Weight and Cost columns in the database are both ints.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire