update fixed report cache..

This commit is contained in:
Cüneyt Şentürk 2021-06-15 14:39:33 +03:00
parent 70e374ac86
commit 33877c90d2
3 changed files with 58 additions and 1 deletions

View File

@ -39,6 +39,5 @@ class Version2116 extends Listener
}
Artisan::call('migrate', ['--force' => true]);
}
}

View File

@ -0,0 +1,57 @@
<?php
namespace App\Listeners\Update\V21;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Models\Common\Company;
use App\Models\Common\Report;
use App\Utilities\Reports as Utility;
use Illuminate\Support\Facades\Artisan;
class Version2117 extends Listener
{
const ALIAS = 'core';
const VERSION = '2.1.17';
/**
* Handle the event.
*
* @param $event
*
* @return void
*/
public function handle(Event $event)
{
if ($this->skipThisUpdate($event)) {
return;
}
$this->updateCompanies();
Artisan::call('migrate', ['--force' => true]);
}
protected function updateCompanies()
{
$company_id = company_id();
$companies = Company::cursor();
foreach ($companies as $company) {
$company->makeCurrent();
$this->cacheReports();
}
company($company_id)->makeCurrent();
}
protected function cacheReports()
{
Report::all()->each(function ($report) {
Cache::put('reports.totals.' . $report->id, Utility::getClassInstance($report)->getGrandTotal());
});
}
}

View File

@ -33,6 +33,7 @@ class Event extends Provider
'App\Listeners\Update\V21\Version2112',
'App\Listeners\Update\V21\Version2114',
'App\Listeners\Update\V21\Version2116',
'App\Listeners\Update\V21\Version2117',
],
'Illuminate\Auth\Events\Login' => [
'App\Listeners\Auth\Login',