added class option to company seed
This commit is contained in:
parent
ee33a211d8
commit
0f5bcfc5b2
@ -3,6 +3,7 @@
|
|||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
||||||
class CompanySeed extends Command
|
class CompanySeed extends Command
|
||||||
{
|
{
|
||||||
@ -11,36 +12,39 @@ class CompanySeed extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'company:seed {company}';
|
protected $signature = 'company:seed {company} {--class= : with Fully Qualified Name}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Seed for specific company';
|
protected $description = 'Run one or all seeds for a specific company';
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$class = $this->laravel->make('CompanySeeder');
|
$class_name = $this->input->getOption('class') ?? 'Database\Seeds\Company';
|
||||||
|
|
||||||
$seeder = $class->setContainer($this->laravel)->setCommand($this);
|
$class = $this->laravel->make($class_name);
|
||||||
|
|
||||||
$seeder->__invoke();
|
$class->setContainer($this->laravel)->setCommand($this)->__invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the console command options.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getOptions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder', 'Database\Seeds\Company'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,8 @@ class UserSeed extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$class = $this->laravel->make('UserSeeder');
|
$class = $this->laravel->make('Database\Seeds\User');
|
||||||
|
|
||||||
$seeder = $class->setContainer($this->laravel)->setCommand($this);
|
$class->setContainer($this->laravel)->setCommand($this)->__invoke();
|
||||||
|
|
||||||
$seeder->__invoke();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,109 +214,18 @@ class Version200 extends Listener
|
|||||||
|
|
||||||
public function createEmailTemplates($company)
|
public function createEmailTemplates($company)
|
||||||
{
|
{
|
||||||
$templates = [
|
Artisan::call('company:seed', [
|
||||||
[
|
'company' => $company->id,
|
||||||
'alias' => 'invoice_new_customer',
|
'--class' => 'Database\Seeders\EmailTemplates',
|
||||||
'class' => 'App\Notifications\Sale\Invoice',
|
|
||||||
'name' => 'settings.email.templates.invoice_new_customer',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'alias' => 'invoice_remind_customer',
|
|
||||||
'class' => 'App\Notifications\Sale\Invoice',
|
|
||||||
'name' => 'settings.email.templates.invoice_remind_customer',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'alias' => 'invoice_remind_admin',
|
|
||||||
'class' => 'App\Notifications\Sale\Invoice',
|
|
||||||
'name' => 'settings.email.templates.invoice_remind_admin',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'alias' => 'invoice_recur_customer',
|
|
||||||
'class' => 'App\Notifications\Sale\Invoice',
|
|
||||||
'name' => 'settings.email.templates.invoice_recur_customer',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'alias' => 'invoice_recur_admin',
|
|
||||||
'class' => 'App\Notifications\Sale\Invoice',
|
|
||||||
'name' => 'settings.email.templates.invoice_recur_admin',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'alias' => 'invoice_payment_customer',
|
|
||||||
'class' => 'App\Notifications\Portal\PaymentReceived',
|
|
||||||
'name' => 'settings.email.templates.invoice_payment_customer',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'alias' => 'invoice_payment_admin',
|
|
||||||
'class' => 'App\Notifications\Portal\PaymentReceived',
|
|
||||||
'name' => 'settings.email.templates.invoice_payment_admin',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'alias' => 'bill_remind_admin',
|
|
||||||
'class' => 'App\Notifications\Purchase\Bill',
|
|
||||||
'name' => 'settings.email.templates.bill_remind_admin',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'alias' => 'bill_recur_admin',
|
|
||||||
'class' => 'App\Notifications\Purchase\Bill',
|
|
||||||
'name' => 'settings.email.templates.bill_recur_admin',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($templates as $template) {
|
|
||||||
EmailTemplate::create([
|
|
||||||
'company_id' => $company->id,
|
|
||||||
'alias' => $template['alias'],
|
|
||||||
'class' => $template['class'],
|
|
||||||
'name' => $template['name'],
|
|
||||||
'subject' => trans('email_templates.' . $template['alias'] . '.subject'),
|
|
||||||
'body' => trans('email_templates.' . $template['alias'] . '.body'),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function createReports($company)
|
public function createReports($company)
|
||||||
{
|
{
|
||||||
$rows = [
|
Artisan::call('company:seed', [
|
||||||
[
|
'company' => $company->id,
|
||||||
'company_id' => $company->id,
|
'--class' => 'Database\Seeders\Reports',
|
||||||
'class' => 'App\Reports\IncomeSummary',
|
]);
|
||||||
'name' => trans('reports.summary.income'),
|
|
||||||
'description' => trans('demo.reports.income'),
|
|
||||||
'settings' => ['group' => 'category', 'period' => 'monthly', 'basis' => 'accrual', 'chart' => 'line'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'company_id' => $company->id,
|
|
||||||
'class' => 'App\Reports\ExpenseSummary',
|
|
||||||
'name' => trans('reports.summary.expense'),
|
|
||||||
'description' => trans('demo.reports.expense'),
|
|
||||||
'settings' => ['group' => 'category', 'period' => 'monthly', 'basis' => 'accrual', 'chart' => 'line'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'company_id' => $company->id,
|
|
||||||
'class' => 'App\Reports\IncomeExpenseSummary',
|
|
||||||
'name' => trans('reports.summary.income_expense'),
|
|
||||||
'description' => trans('demo.reports.income_expense'),
|
|
||||||
'settings' => ['group' => 'category', 'period' => 'monthly', 'basis' => 'accrual', 'chart' => 'line'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'company_id' => $company->id,
|
|
||||||
'class' => 'App\Reports\ProfitLoss',
|
|
||||||
'name' => trans('reports.profit_loss'),
|
|
||||||
'description' => trans('demo.reports.profit_loss'),
|
|
||||||
'settings' => ['group' => 'category', 'period' => 'quarterly', 'basis' => 'accrual'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'company_id' => $company->id,
|
|
||||||
'class' => 'App\Reports\TaxSummary',
|
|
||||||
'name' => trans('reports.summary.tax'),
|
|
||||||
'description' => trans('demo.reports.tax'),
|
|
||||||
'settings' => ['period' => 'quarterly', 'basis' => 'accrual'],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
Report::create($row);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createDashboards()
|
public function createDashboards()
|
||||||
@ -971,6 +880,7 @@ class Version200 extends Listener
|
|||||||
'config/modules.php',
|
'config/modules.php',
|
||||||
'docker-compose.yml',
|
'docker-compose.yml',
|
||||||
'database/seeds/Roles.php',
|
'database/seeds/Roles.php',
|
||||||
|
'database/seeds/CompanySeeder.php',
|
||||||
'Dockerfile',
|
'Dockerfile',
|
||||||
'modules/PaypalStandard/Http/Controllers/PaypalStandard.php',
|
'modules/PaypalStandard/Http/Controllers/PaypalStandard.php',
|
||||||
'modules/PaypalStandard/Http/routes.php',
|
'modules/PaypalStandard/Http/routes.php',
|
||||||
|
24
database/seeds/Company.php
Normal file
24
database/seeds/Company.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeds;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class Company extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$this->call(Accounts::class);
|
||||||
|
$this->call(Categories::class);
|
||||||
|
$this->call(Currencies::class);
|
||||||
|
$this->call(EmailTemplates::class);
|
||||||
|
$this->call(Modules::class);
|
||||||
|
$this->call(Reports::class);
|
||||||
|
$this->call(Settings::class);
|
||||||
|
}
|
||||||
|
}
|
@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
|
||||||
|
|
||||||
class CompanySeeder extends Seeder
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the database seeds.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function run()
|
|
||||||
{
|
|
||||||
$this->call(Database\Seeds\Accounts::class);
|
|
||||||
$this->call(Database\Seeds\Categories::class);
|
|
||||||
$this->call(Database\Seeds\Currencies::class);
|
|
||||||
$this->call(Database\Seeds\EmailTemplates::class);
|
|
||||||
$this->call(Database\Seeds\Modules::class);
|
|
||||||
$this->call(Database\Seeds\Reports::class);
|
|
||||||
$this->call(Database\Seeds\Settings::class);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeds;
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class UserSeeder extends Seeder
|
class User extends Seeder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the database seeds.
|
* Run the database seeds.
|
||||||
@ -11,6 +13,6 @@ class UserSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$this->call(Database\Seeds\Dashboards::class);
|
$this->call(Dashboards::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user