Added home page pricing break down func to cache
Added home page pricing break down func to cache
This commit is contained in:
parent
f72eec01f7
commit
8e5a1f62c3
|
@ -60,6 +60,7 @@ class SettingsController extends Controller
|
|||
|
||||
Cache::forget('due_soon');//Main page due_soon cache
|
||||
Cache::forget('recently_added');//Main page recently_added cache
|
||||
Cache::forget('pricing_breakdown');//Main page pricing breakdown
|
||||
|
||||
Cache::forget('settings');//Main page settings cache
|
||||
|
||||
|
|
|
@ -116,45 +116,47 @@ class Home extends Model
|
|||
{
|
||||
$pricing = json_decode($all_pricing, true);
|
||||
|
||||
$total_cost_weekly = $total_cost_pm = $inactive_count = 0;
|
||||
foreach ($pricing as $price) {
|
||||
if ($price['active'] === 1) {
|
||||
if (Session::get('dashboard_currency') !== 'USD') {
|
||||
$the_price = Pricing::convertFromUSD($price['as_usd'], Session::get('dashboard_currency'));
|
||||
return Cache::remember('pricing_breakdown', now()->addWeek(1), function () use ($pricing) {
|
||||
$total_cost_weekly = $total_cost_pm = $inactive_count = 0;
|
||||
foreach ($pricing as $price) {
|
||||
if ($price['active'] === 1) {
|
||||
if (Session::get('dashboard_currency') !== 'USD') {
|
||||
$the_price = Pricing::convertFromUSD($price['as_usd'], Session::get('dashboard_currency'));
|
||||
} else {
|
||||
$the_price = $price['as_usd'];
|
||||
}
|
||||
if ($price['term'] === 1) {//1 month
|
||||
$total_cost_weekly += ($the_price / 4);
|
||||
$total_cost_pm += $the_price;
|
||||
} elseif ($price['term'] === 2) {//3 months
|
||||
$total_cost_weekly += ($the_price / 12);
|
||||
$total_cost_pm += ($the_price / 3);
|
||||
} elseif ($price['term'] === 3) {// 6 month
|
||||
$total_cost_weekly += ($the_price / 24);
|
||||
$total_cost_pm += ($the_price / 6);
|
||||
} elseif ($price['term'] === 4) {// 1 year
|
||||
$total_cost_weekly += ($the_price / 48);
|
||||
$total_cost_pm += ($the_price / 12);
|
||||
} elseif ($price['term'] === 5) {//2 years
|
||||
$total_cost_weekly += ($the_price / 96);
|
||||
$total_cost_pm += ($the_price / 24);
|
||||
} elseif ($price['term'] === 6) {//3 years
|
||||
$total_cost_weekly += ($the_price / 144);
|
||||
$total_cost_pm += ($the_price / 36);
|
||||
}
|
||||
} else {
|
||||
$the_price = $price['as_usd'];
|
||||
$inactive_count++;
|
||||
}
|
||||
if ($price['term'] === 1) {//1 month
|
||||
$total_cost_weekly += ($the_price / 4);
|
||||
$total_cost_pm += $the_price;
|
||||
} elseif ($price['term'] === 2) {//3 months
|
||||
$total_cost_weekly += ($the_price / 12);
|
||||
$total_cost_pm += ($the_price / 3);
|
||||
} elseif ($price['term'] === 3) {// 6 month
|
||||
$total_cost_weekly += ($the_price / 24);
|
||||
$total_cost_pm += ($the_price / 6);
|
||||
} elseif ($price['term'] === 4) {// 1 year
|
||||
$total_cost_weekly += ($the_price / 48);
|
||||
$total_cost_pm += ($the_price / 12);
|
||||
} elseif ($price['term'] === 5) {//2 years
|
||||
$total_cost_weekly += ($the_price / 96);
|
||||
$total_cost_pm += ($the_price / 24);
|
||||
} elseif ($price['term'] === 6) {//3 years
|
||||
$total_cost_weekly += ($the_price / 144);
|
||||
$total_cost_pm += ($the_price / 36);
|
||||
}
|
||||
} else {
|
||||
$inactive_count++;
|
||||
}
|
||||
}
|
||||
$total_cost_yearly = ($total_cost_pm * 12);
|
||||
$total_cost_yearly = ($total_cost_pm * 12);
|
||||
|
||||
return array(
|
||||
'total_cost_weekly' => $total_cost_weekly,
|
||||
'total_cost_montly' => $total_cost_pm,
|
||||
'total_cost_yearly' => $total_cost_yearly,
|
||||
'inactive_count' => $inactive_count,
|
||||
);
|
||||
return array(
|
||||
'total_cost_weekly' => $total_cost_weekly,
|
||||
'total_cost_montly' => $total_cost_pm,
|
||||
'total_cost_yearly' => $total_cost_yearly,
|
||||
'inactive_count' => $inactive_count,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public static function doServicesCount($services_count): array
|
||||
|
|
Loading…
Reference in New Issue
Block a user