Skip to content

Commit

Permalink
update fixed report cache..
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jun 15, 2021
1 parent 70e374a commit 33877c9
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/Listeners/Update/V21/Version2116.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@ public function handle(Event $event)
}

Artisan::call('migrate', ['--force' => true]);

}
}
57 changes: 57 additions & 0 deletions app/Listeners/Update/V21/Version2117.php
Original file line number Diff line number Diff line change
@@ -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());
});
}
}
1 change: 1 addition & 0 deletions app/Providers/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 33877c9

Please sign in to comment.