refs #1282 add update missing column.
This commit is contained in:
parent
46e2be41d7
commit
f1f4d42e83
67
app/Listeners/Update/V20/Version203.php
Normal file
67
app/Listeners/Update/V20/Version203.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\Update\V20;
|
||||
|
||||
use App\Abstracts\Listeners\Update as Listener;
|
||||
use App\Events\Install\UpdateFinished as Event;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Utilities\Overrider;
|
||||
|
||||
class Version203 extends Listener
|
||||
{
|
||||
const ALIAS = 'core';
|
||||
|
||||
const VERSION = '2.0.3';
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
{
|
||||
if ($this->skipThisUpdate($event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->updateCompanies();
|
||||
}
|
||||
|
||||
protected function updateCompanies()
|
||||
{
|
||||
$company_id = session('company_id');
|
||||
|
||||
$companies = DB::table('companies')
|
||||
->whereNotExists(function ($query) {
|
||||
$query->select('id')
|
||||
->from('settings')
|
||||
->where('key', 'invoice.payment_terms');
|
||||
})
|
||||
->cursor();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
session(['company_id' => $company->id]);
|
||||
|
||||
$this->updateSettings($company);
|
||||
}
|
||||
|
||||
setting()->forgetAll();
|
||||
|
||||
session(['company_id' => $company_id]);
|
||||
|
||||
Overrider::load('settings');
|
||||
}
|
||||
|
||||
public function updateSettings($company)
|
||||
{
|
||||
// Set the active company settings
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
setting()->forgetAll();
|
||||
setting()->load(true);
|
||||
|
||||
setting()->set(['invoice.payment_terms' => setting('invoice.payment_terms', 0)]);
|
||||
|
||||
setting()->save();
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ class Event extends Provider
|
||||
'App\Events\Install\UpdateFinished' => [
|
||||
'App\Listeners\Update\CreateModuleUpdatedHistory',
|
||||
'App\Listeners\Update\V20\Version200',
|
||||
'App\Listeners\Update\V20\Version203',
|
||||
],
|
||||
'Illuminate\Auth\Events\Login' => [
|
||||
'App\Listeners\Auth\Login',
|
||||
|
Loading…
x
Reference in New Issue
Block a user