refactored report and update abstracts

This commit is contained in:
denisdulici 2019-11-23 21:47:20 +03:00
parent eef7eaa12f
commit 51a7fa86fc
37 changed files with 54 additions and 48 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Abstracts\Reports; namespace App\Abstracts\Listeners;
use App\Events\Common\ReportFilterApplying; use App\Events\Common\ReportFilterApplying;
use App\Events\Common\ReportFilterShowing; use App\Events\Common\ReportFilterShowing;
@ -12,7 +12,7 @@ use App\Models\Setting\Category;
use App\Traits\Contacts; use App\Traits\Contacts;
use Date; use Date;
abstract class Listener abstract class Report
{ {
use Contacts; use Contacts;

View File

@ -1,31 +1,39 @@
<?php <?php
namespace App\Listeners\Update; namespace App\Abstracts\Listeners;
class Listener abstract class Update
{ {
const ALIAS = ''; const ALIAS = '';
const VERSION = ''; const VERSION = '';
/** /**
* Check if should listen. * Check the fired update based on alias and version.
* *
* @param $event * @param $event
* @return boolean * @return boolean
*/ */
protected function check($event) public function skipThisUpdate($event)
{ {
// Apply only to the specified alias // Apply only to the specified alias
if ($event->alias != static::ALIAS) { if ($event->alias != static::ALIAS) {
return false; return true;
} }
// Do not apply to the same or newer versions // Do not apply to the same or newer versions
if (version_compare($event->old, static::VERSION, '>=')) { if (version_compare($event->old, static::VERSION, '>=')) {
return true;
}
return false; return false;
} }
return true; /**
* @deprecated since 2.0
*/
public function check($event)
{
return !$this->skipThisUpdate($event);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Abstracts\Reports; namespace App\Abstracts;
use App\Exports\Common\Reports as Export; use App\Exports\Common\Reports as Export;
use App\Models\Common\Report as Model; use App\Models\Common\Report as Model;

View File

@ -2,7 +2,7 @@
namespace App\Listeners\Common; namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener; use App\Abstracts\Listeners\Report as Listener;
use App\Events\Common\ReportFilterApplying; use App\Events\Common\ReportFilterApplying;
use App\Events\Common\ReportFilterShowing; use App\Events\Common\ReportFilterShowing;
use App\Events\Common\ReportGroupApplying; use App\Events\Common\ReportGroupApplying;

View File

@ -2,7 +2,7 @@
namespace App\Listeners\Common; namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener; use App\Abstracts\Listeners\Report as Listener;
use App\Events\Common\ReportFilterApplying; use App\Events\Common\ReportFilterApplying;
use App\Events\Common\ReportFilterShowing; use App\Events\Common\ReportFilterShowing;
use App\Events\Common\ReportGroupApplying; use App\Events\Common\ReportGroupApplying;

View File

@ -2,7 +2,7 @@
namespace App\Listeners\Common; namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener; use App\Abstracts\Listeners\Report as Listener;
use App\Events\Common\ReportFilterApplying; use App\Events\Common\ReportFilterApplying;
use App\Events\Common\ReportFilterShowing; use App\Events\Common\ReportFilterShowing;
use App\Events\Common\ReportGroupApplying; use App\Events\Common\ReportGroupApplying;

View File

@ -2,7 +2,7 @@
namespace App\Listeners\Common; namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener; use App\Abstracts\Listeners\Report as Listener;
class ProfitLossReport extends Listener class ProfitLossReport extends Listener
{ {

View File

@ -2,7 +2,7 @@
namespace App\Listeners\Common; namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener; use App\Abstracts\Listeners\Report as Listener;
class TaxSummaryReport extends Listener class TaxSummaryReport extends Listener
{ {

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V10; namespace App\Listeners\Update\V10;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use File; use File;
class Version106 extends Listener class Version106 extends Listener

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V10; namespace App\Listeners\Update\V10;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use DB; use DB;
class Version107 extends Listener class Version107 extends Listener

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V10; namespace App\Listeners\Update\V10;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company; use App\Models\Common\Company;
use App\Models\Expense\Bill; use App\Models\Expense\Bill;
use App\Models\Expense\BillStatus; use App\Models\Expense\BillStatus;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V10; namespace App\Listeners\Update\V10;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company; use App\Models\Common\Company;
use Artisan; use Artisan;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V11; namespace App\Listeners\Update\V11;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V11; namespace App\Listeners\Update\V11;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company; use App\Models\Common\Company;
use App\Utilities\Installer; use App\Utilities\Installer;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V11; namespace App\Listeners\Update\V11;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Setting\Currency; use App\Models\Setting\Currency;
use Artisan; use Artisan;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V11; namespace App\Listeners\Update\V11;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V12; namespace App\Listeners\Update\V12;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;
use App\Models\Common\Company; use App\Models\Common\Company;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V12; namespace App\Listeners\Update\V12;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Artisan; use Artisan;
class Version1210 extends Listener class Version1210 extends Listener

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V12; namespace App\Listeners\Update\V12;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Artisan; use Artisan;
class Version1211 extends Listener class Version1211 extends Listener

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V12; namespace App\Listeners\Update\V12;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V12; namespace App\Listeners\Update\V12;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;
use File; use File;
use Illuminate\Support\Str; use Illuminate\Support\Str;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V12; namespace App\Listeners\Update\V12;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Artisan; use Artisan;
class Version129 extends Listener class Version129 extends Listener

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V13; namespace App\Listeners\Update\V13;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;
use Artisan; use Artisan;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V13; namespace App\Listeners\Update\V13;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;
use Artisan; use Artisan;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V13; namespace App\Listeners\Update\V13;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company; use App\Models\Common\Company;
use App\Utilities\Installer; use App\Utilities\Installer;
use Artisan; use Artisan;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V13; namespace App\Listeners\Update\V13;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company; use App\Models\Common\Company;
use App\Utilities\Overrider; use App\Utilities\Overrider;
use App\Models\Banking\Account; use App\Models\Banking\Account;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V13; namespace App\Listeners\Update\V13;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;
use Artisan; use Artisan;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V13; namespace App\Listeners\Update\V13;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Date; use Date;
class Version135 extends Listener class Version135 extends Listener

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V13; namespace App\Listeners\Update\V13;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Date; use Date;
class Version138 extends Listener class Version138 extends Listener

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V13; namespace App\Listeners\Update\V13;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Income\InvoiceItem; use App\Models\Income\InvoiceItem;
use App\Models\Income\InvoiceItemTax; use App\Models\Income\InvoiceItemTax;
use App\Models\Setting\Tax; use App\Models\Setting\Tax;

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V20; namespace App\Listeners\Update\V20;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\User; use App\Models\Auth\User;
use App\Models\Auth\Role; use App\Models\Auth\Role;
use App\Models\Auth\Permission; use App\Models\Auth\Permission;
@ -32,8 +32,7 @@ class Version200 extends Listener
*/ */
public function handle(Event $event) public function handle(Event $event)
{ {
// Check if should listen if ($this->skipThisUpdate($event)) {
if (!$this->check($event)) {
return; return;
} }

View File

@ -2,8 +2,8 @@
namespace App\Listeners\Update\V13; namespace App\Listeners\Update\V13;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Artisan; use Artisan;
class Version201 extends Listener class Version201 extends Listener
@ -20,8 +20,7 @@ class Version201 extends Listener
*/ */
public function handle(Event $event) public function handle(Event $event)
{ {
// Check if should listen if ($this->skipThisUpdate($event)) {
if (!$this->check($event)) {
return; return;
} }

View File

@ -2,7 +2,7 @@
namespace App\Reports; namespace App\Reports;
use App\Abstracts\Reports\Report; use App\Abstracts\Report;
use App\Models\Banking\Transaction; use App\Models\Banking\Transaction;
use App\Models\Expense\Bill; use App\Models\Expense\Bill;
use App\Utilities\Recurring; use App\Utilities\Recurring;

View File

@ -2,7 +2,7 @@
namespace App\Reports; namespace App\Reports;
use App\Abstracts\Reports\Report; use App\Abstracts\Report;
use App\Models\Banking\Transaction; use App\Models\Banking\Transaction;
use App\Models\Expense\Bill; use App\Models\Expense\Bill;
use App\Models\Income\Invoice; use App\Models\Income\Invoice;

View File

@ -2,7 +2,7 @@
namespace App\Reports; namespace App\Reports;
use App\Abstracts\Reports\Report; use App\Abstracts\Report;
use App\Models\Banking\Transaction; use App\Models\Banking\Transaction;
use App\Models\Income\Invoice; use App\Models\Income\Invoice;
use App\Utilities\Recurring; use App\Utilities\Recurring;

View File

@ -2,7 +2,7 @@
namespace App\Reports; namespace App\Reports;
use App\Abstracts\Reports\Report; use App\Abstracts\Report;
use App\Models\Banking\Transaction; use App\Models\Banking\Transaction;
use App\Models\Expense\Bill; use App\Models\Expense\Bill;
use App\Models\Income\Invoice; use App\Models\Income\Invoice;

View File

@ -2,7 +2,7 @@
namespace App\Reports; namespace App\Reports;
use App\Abstracts\Reports\Report; use App\Abstracts\Report;
use App\Models\Banking\Transaction; use App\Models\Banking\Transaction;
use App\Models\Expense\Bill; use App\Models\Expense\Bill;
use App\Models\Income\Invoice; use App\Models\Income\Invoice;