Report page cache own widget..

This commit is contained in:
Cüneyt Şentürk
2021-06-15 12:37:13 +03:00
parent c005e21738
commit 0bbc31bec4
6 changed files with 49 additions and 14 deletions

View File

@ -142,7 +142,7 @@ abstract class Report
$sum += is_array($total) ? array_sum($total) : $total;
}
$total = money($sum, setting('default.currency'), true);
$total = money($sum, setting('default.currency'), true)->format();
} else {
$total = trans('general.na');
}

View File

@ -67,6 +67,8 @@ class ReportReminder extends Command
$ttl = 3600 * 6; // 6 hours
Cache::forget('reports.totals.' . $report->id);
Cache::remember('reports.totals.' . $report->id, $ttl, function () use ($class) {
return $class->getGrandTotal();
});

View File

@ -24,6 +24,7 @@ class Reports extends Controller
$this->middleware('permission:update-common-reports')->only('edit', 'update', 'enable', 'disable');
$this->middleware('permission:delete-common-reports')->only('destroy');
}
/**
* Display a listing of the resource.
*
@ -271,16 +272,17 @@ class Reports extends Controller
*
* @return Response
*/
public function clear()
public function clear(Report $report)
{
Report::all()->each(function ($report) {
if (!Utility::canShow($report->class)) {
return;
}
$data = Utility::getClassInstance($report)->getGrandTotal();
Cache::put('reports.totals.' . $report->id, Utility::getClassInstance($report)->getGrandTotal());
});
Cache::put('reports.totals.' . $report->id, $data);
return redirect()->back();
return response()->json([
'success' => true,
'error' => false,
'data' => $data,
'message' => '',
]);
}
}