L5 Syntax - Cache for Currency
This commit is contained in:
parent
de1a5252ec
commit
7c78753a2d
2 changed files with 10 additions and 5 deletions
|
|
@ -1,8 +1,11 @@
|
|||
<?php namespace App\Libraries;
|
||||
|
||||
use Auth;
|
||||
use Cache;
|
||||
use DB;
|
||||
use Schema;
|
||||
use Session;
|
||||
use App\Models\Currency;
|
||||
|
||||
class Utils
|
||||
{
|
||||
|
|
@ -221,12 +224,14 @@ class Utils
|
|||
$currencyId = Session::get(SESSION_CURRENCY);
|
||||
}
|
||||
|
||||
$currency = Currency::remember(DEFAULT_QUERY_CACHE)->find($currencyId);
|
||||
|
||||
if (!$currency) {
|
||||
$currency = Currency::remember(DEFAULT_QUERY_CACHE)->find(1);
|
||||
$currency = Currency::find($currencyId);
|
||||
|
||||
if(!$currency){
|
||||
$currency = Currency::find(1);
|
||||
}
|
||||
|
||||
Cache::add('currency', $currency, DEFAULT_QUERY_CACHE);
|
||||
|
||||
return $currency->symbol.number_format($value, $currency->precision, $currency->decimal_separator, $currency->thousand_separator);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script type="text/javascript">
|
||||
|
||||
var currencies = {{ \Cache::pull('currency') }};
|
||||
var currencies = {!! \Cache::pull('currency') !!};
|
||||
var currencyMap = {};
|
||||
for (var i=0; i<currencies.length; i++) {
|
||||
var currency = currencies[i];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue