v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@ -15,12 +15,10 @@ $factory->define(Item::class, function (Generator $faker) {
return [
'name' => $faker->title,
'sku' => $faker->languageCode,
'company_id' => $company->id,
'description' => $faker->text(100),
'purchase_price' => $faker->randomFloat(2,10,20),
'sale_price' => $faker->randomFloat(2,10,20),
'quantity' => $faker->randomNumber(2),
'category_id' => $company->categories()->first()->id,
'tax_id' => $company->taxes()->first()->id,
'enabled' => $this->faker->boolean ? 1 : 0

View File

@ -19,6 +19,6 @@ $factory->define(\App\Models\Auth\User::class, function (Faker\Generator $faker)
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
'remember_token' => \Str::random(10),
];
});

View File

@ -14,7 +14,7 @@ class CreateCompaniesTable extends Migration
{
Schema::create('companies', function (Blueprint $table) {
$table->increments('id');
$table->string('domain');
$table->string('domain')->nullable();
$table->boolean('enabled')->default(1);
$table->timestamps();
$table->softDeletes();

View File

@ -1,13 +1,14 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use App\Models\Model;
use App\Models\Company\Company;
use App\Abstracts\Model;
use App\Models\Common\Company;
use App\Models\Expense\Bill;
use App\Models\Expense\BillItem;
use App\Models\Expense\BillTotal;
use App\Models\Setting\Tax;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateBillTotalsTable extends Migration
{

View File

@ -1,13 +1,13 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use App\Models\Model;
use App\Models\Company\Company;
use App\Abstracts\Model;
use App\Models\Common\Company;
use App\Models\Income\Invoice;
use App\Models\Income\InvoiceItem;
use App\Models\Income\InvoiceTotal;
use App\Models\Setting\Tax;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateInvoiceTotalsTable extends Migration
{

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
class AddFooterColumnInvoicesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('invoices', function ($table) {
$table->text('footer')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('invoices', function ($table) {
$table->dropColumn('footer');
});
}
}

View File

@ -0,0 +1,76 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateContactsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contacts', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('type');
$table->string('name');
$table->string('email')->nullable();
$table->integer('user_id')->nullable();
$table->string('tax_number')->nullable();
$table->string('phone')->nullable();
$table->text('address')->nullable();
$table->string('website')->nullable();
$table->string('currency_code', 3);
$table->boolean('enabled');
$table->string('reference')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['company_id', 'type']);
$table->unique(['company_id', 'type', 'email', 'deleted_at']);
});
$rename_bills = [
'vendor_id' => 'contact_id',
'vendor_name' => 'contact_name',
'vendor_email' => 'contact_email',
'vendor_tax_number' => 'contact_tax_number',
'vendor_phone' => 'contact_phone',
'vendor_address' => 'contact_address',
];
foreach ($rename_bills as $from => $to) {
Schema::table('bills', function (Blueprint $table) use ($from, $to) {
$table->renameColumn($from, $to);
});
}
$rename_invoices = [
'customer_id' => 'contact_id',
'customer_name' => 'contact_name',
'customer_email' => 'contact_email',
'customer_tax_number' => 'contact_tax_number',
'customer_phone' => 'contact_phone',
'customer_address' => 'contact_address',
];
foreach ($rename_invoices as $from => $to) {
Schema::table('invoices', function (Blueprint $table) use ($from, $to) {
$table->renameColumn($from, $to);
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('contacts');
}
}

View File

@ -0,0 +1,67 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateDashboardsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('dashboards', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('user_id');
$table->string('name');
$table->boolean('enabled')->default(1);
$table->timestamps();
$table->softDeletes();
$table->index(['company_id']);
});
Schema::create('dashboard_widgets', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->integer('user_id');
$table->integer('dashboard_id');
$table->integer('widget_id');
$table->string('name');
$table->text('settings')->nullable();
$table->integer('sort')->default(0);
$table->timestamps();
$table->softDeletes();
$table->index(['company_id']);
});
Schema::create('widgets', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->string('alias');
$table->text('settings')->nullable();
$table->boolean('enabled')->default(1);
$table->timestamps();
$table->softDeletes();
$table->index(['company_id', 'alias']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('dashboards');
Schema::drop('dashboard_widgets');
Schema::drop('widgets');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateEmailTemplatesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('email_templates', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('alias');
$table->string('subject');
$table->text('body');
$table->text('params')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
$table->unique(['company_id', 'alias', 'deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('email_templates');
}
}

View File

@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateFirewallTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('firewall_ips', function (Blueprint $table) {
$table->increments('id');
$table->string('ip');
$table->integer('log_id')->nullable();
$table->boolean('blocked')->default(1);
$table->timestamps();
$table->softDeletes();
$table->index('ip');
$table->unique(['ip', 'deleted_at']);
});
Schema::create('firewall_logs', function (Blueprint $table) {
$table->increments('id');
$table->string('ip');
$table->string('level')->default('medium');
$table->string('middleware');
$table->integer('user_id')->nullable();
$table->string('url')->nullable();
$table->string('referrer')->nullable();
$table->text('request')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('ip');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('firewall_ips');
Schema::drop('firewall_logs');
}
}

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateReportsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('reports', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('name');
$table->text('description');
$table->string('class');
$table->string('group');
$table->string('period');
$table->string('basis');
$table->string('chart');
$table->boolean('enabled');
$table->timestamps();
$table->softDeletes();
$table->index('company_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('reports');
}
}

View File

@ -0,0 +1,56 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateTransactionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transactions', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('type');
$table->integer('account_id');
$table->dateTime('paid_at');
$table->double('amount', 15, 4);
$table->string('currency_code', 3);
$table->double('currency_rate', 15, 8);
$table->integer('document_id')->nullable();
$table->integer('contact_id')->nullable();
$table->text('description')->nullable();
$table->integer('category_id');
$table->string('payment_method');
$table->string('reference')->nullable();
$table->integer('parent_id')->default(0);
$table->boolean('reconciled')->default(0);
$table->timestamps();
$table->softDeletes();
$table->index(['company_id', 'type']);
});
Schema::table('transfers', function (Blueprint $table) {
$table->renameColumn('payment_id', 'expense_transaction_id');
});
Schema::table('transfers', function (Blueprint $table) {
$table->renameColumn('revenue_id', 'income_transaction_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transactions');
}
}

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class ModifyDomainColumnCompaniesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('companies', function (Blueprint $table) {
$table->string('domain')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('companies', function (Blueprint $table) {
$table->string('domain')->change();
});
}
}

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class ModifyStatusColumnModulesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('modules', function (Blueprint $table) {
$table->renameColumn('status', 'enabled');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('modules', function (Blueprint $table) {
$table->renameColumn('enabled', 'status');
});
}
}

View File

@ -2,7 +2,7 @@
namespace Database\Seeds;
use App\Models\Model;
use App\Abstracts\Model;
use App\Models\Banking\Account;
use Illuminate\Database\Seeder;
@ -43,7 +43,7 @@ class Accounts extends Seeder
foreach ($rows as $row) {
$account = Account::create($row);
setting()->set('general.default_account', $account->id);
setting()->set('default.account', $account->id);
}
}
}

View File

@ -2,7 +2,7 @@
namespace Database\Seeds;
use App\Models\Model;
use App\Abstracts\Model;
use App\Models\Expense\BillStatus;
use Illuminate\Database\Seeder;

View File

@ -2,7 +2,7 @@
namespace Database\Seeds;
use App\Models\Model;
use App\Abstracts\Model;
use App\Models\Setting\Category;
use Illuminate\Database\Seeder;
@ -31,14 +31,14 @@ class Categories extends Seeder
'company_id' => $company_id,
'name' => trans_choice('general.transfers', 1),
'type' => 'other',
'color' => '#605ca8',
'color' => '#3c3f72',
'enabled' => '1'
],
[
'company_id' => $company_id,
'name' => trans('demo.categories_deposit'),
'type' => 'income',
'color' => '#f39c12',
'color' => '#efad32',
'enabled' => '1'
],
[
@ -52,14 +52,14 @@ class Categories extends Seeder
'company_id' => $company_id,
'name' => trans_choice('general.others', 1),
'type' => 'expense',
'color' => '#d2d6de',
'color' => '#e5e5e5',
'enabled' => '1'
],
[
'company_id' => $company_id,
'name' => trans('general.general'),
'type' => 'item',
'color' => '#00c0ef',
'color' => '#328aef',
'enabled' => '1'
],
];

View File

@ -15,8 +15,10 @@ class CompanySeeder extends Seeder
$this->call(Database\Seeds\BillStatuses::class);
$this->call(Database\Seeds\Categories::class);
$this->call(Database\Seeds\Currencies::class);
$this->call(Database\Seeds\EmailTemplates::class);
$this->call(Database\Seeds\InvoiceStatuses::class);
$this->call(Database\Seeds\Modules::class);
$this->call(Database\Seeds\Reports::class);
$this->call(Database\Seeds\Settings::class);
}
}

View File

@ -2,7 +2,7 @@
namespace Database\Seeds;
use App\Models\Model;
use App\Abstracts\Model;
use App\Models\Setting\Currency;
use Illuminate\Database\Seeder;

View File

@ -0,0 +1,63 @@
<?php
namespace Database\Seeds;
use App\Abstracts\Model;
use App\Models\Common\Widget;
use App\Models\Common\Dashboard;
use App\Models\Common\DashboardWidget;
use Illuminate\Database\Seeder;
class Dashboards extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->create();
Model::reguard();
}
private function create()
{
$user_id = $this->command->argument('user');
$company_id = $this->command->argument('company');
$rows = [
[
'company_id' => $company_id,
'user_id' => $user_id,
'name' => trans('general.dashboard'),
'enabled' => 1,
]
];
foreach ($rows as $row) {
$dashboard = Dashboard::create($row);
$widgets = Widget::where('company_id', $company_id)->orderBy('created_at','desc')->get();
$sort = 1;
foreach ($widgets as $widget) {
DashboardWidget::create([
'company_id' => $company_id,
'user_id' => $user_id,
'dashboard_id' => $dashboard->id,
'widget_id' => $widget->id,
'name' => $widget->name,
'settings' => $widget->settings,
'sort' => $sort
]);
$sort++;
}
}
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace Database\Seeds;
use App\Abstracts\Model;
use App\Models\Common\EmailTemplate;
use Illuminate\Database\Seeder;
class EmailTemplates extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->create();
Model::reguard();
}
private function create()
{
$company_id = $this->command->argument('company');
$templates = [
'invoice_new_customer',
'invoice_remind_customer',
'invoice_remind_admin',
'invoice_recur_customer',
'invoice_recur_admin',
'invoice_payment_customer',
'invoice_payment_admin',
'bill_remind_admin',
'bill_recur_admin',
];
foreach ($templates as $template) {
EmailTemplate::create([
'company_id' => $company_id,
'alias' => $template,
'subject' => trans('email_templates.' . $template . '.subject'),
'body' => trans('email_templates.' . $template . '.body'),
]);
}
}
}

View File

@ -2,7 +2,7 @@
namespace Database\Seeds;
use App\Models\Model;
use App\Abstracts\Model;
use App\Models\Income\InvoiceStatus;
use Illuminate\Database\Seeder;

View File

@ -2,7 +2,7 @@
namespace Database\Seeds;
use App\Models\Model;
use App\Abstracts\Model;
use Artisan;
use Illuminate\Database\Seeder;
@ -26,7 +26,7 @@ class Modules extends Seeder
{
$company_id = $this->command->argument('company');
Artisan::call('module:install', ['alias' => 'offlinepayment', 'company_id' => $company_id]);
Artisan::call('module:install', ['alias' => 'paypalstandard', 'company_id' => $company_id]);
Artisan::call('module:install', ['alias' => 'offline-payments', 'company_id' => $company_id]);
Artisan::call('module:install', ['alias' => 'paypal-standard', 'company_id' => $company_id]);
}
}

View File

@ -0,0 +1,91 @@
<?php
namespace Database\Seeds;
use App\Abstracts\Model;
use App\Models\Common\Report;
use Illuminate\Database\Seeder;
class Reports extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->create();
Model::reguard();
}
private function create()
{
$company_id = $this->command->argument('company');
$rows = [
[
'company_id' => $company_id,
'name' => trans('reports.summary.income'),
'description' => 'This is the income summary by category.',
'class' => 'App\Reports\IncomeSummary',
'group' => 'category',
'period' => 'monthly',
'basis' => 'accrual',
'chart' => 'line',
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('reports.summary.expense'),
'description' => 'This is the expense summary by category.',
'class' => 'App\Reports\ExpenseSummary',
'group' => 'category',
'period' => 'monthly',
'basis' => 'accrual',
'chart' => 'line',
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('reports.summary.income_expense'),
'description' => 'This is the income vs expense by category.',
'class' => 'App\Reports\IncomeExpenseSummary',
'group' => 'category',
'period' => 'monthly',
'basis' => 'accrual',
'chart' => 'line',
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('reports.summary.tax'),
'description' => 'This is the tax summary by category.',
'class' => 'App\Reports\TaxSummary',
'group' => 'category',
'period' => 'quarterly',
'basis' => 'accrual',
'chart' => '0',
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('reports.profit_loss'),
'description' => 'This is the profit & loss by category.',
'class' => 'App\Reports\ProfitLoss',
'group' => 'category',
'period' => 'quarterly',
'basis' => 'accrual',
'chart' => '0',
'enabled' => 1,
],
];
foreach ($rows as $row) {
Report::create($row);
}
}
}

View File

@ -2,7 +2,7 @@
namespace Database\Seeds;
use App\Models\Model;
use App\Abstracts\Model;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use Illuminate\Database\Seeder;
@ -29,84 +29,103 @@ class Roles extends Seeder
'admin' => [
'admin-panel' => 'r',
'api' => 'r',
'auth-users' => 'c,r,u,d',
'auth-roles' => 'c,r,u,d',
'auth-permissions' => 'c,r,u,d',
'auth-profile' => 'r,u',
'auth-roles' => 'c,r,u,d',
'auth-users' => 'c,r,u,d',
'banking-accounts' => 'c,r,u,d',
'banking-reconciliations' => 'c,r,u,d',
'banking-transactions' => 'c,r,u,d',
'banking-transfers' => 'c,r,u,d',
'common-companies' => 'c,r,u,d',
'common-import' => 'c',
'common-items' => 'c,r,u,d',
'common-uploads' => 'r,d',
'common-notifications' => 'c,r,u,d',
'incomes-invoices' => 'c,r,u,d',
'incomes-revenues' => 'c,r,u,d',
'incomes-customers' => 'c,r,u,d',
'common-reports' => 'c,r,u,d',
'common-search' => 'r',
'common-uploads' => 'r,d',
'common-widgets' => 'c,r,u,d',
'expenses-bills' => 'c,r,u,d',
'expenses-payments' => 'c,r,u,d',
'expenses-vendors' => 'c,r,u,d',
'banking-accounts' => 'c,r,u,d',
'banking-transfers' => 'c,r,u,d',
'banking-transactions' => 'r',
'banking-reconciliations' => 'c,r,u,d',
'settings-categories' => 'c,r,u,d',
'settings-settings' => 'r,u',
'settings-taxes' => 'c,r,u,d',
'settings-currencies' => 'c,r,u,d',
'settings-modules' => 'r,u',
'modules-home' => 'r',
'modules-tiles' => 'r',
'modules-item' => 'c,r,u,d',
'modules-token' => 'c,u',
'modules-my' => 'r',
'incomes-customers' => 'c,r,u,d',
'incomes-invoices' => 'c,r,u,d',
'incomes-revenues' => 'c,r,u,d',
'install-updates' => 'r,u',
'modules-api-key' => 'c,u',
'modules-home' => 'r',
'modules-item' => 'c,r,u,d',
'modules-my' => 'r',
'modules-tiles' => 'r',
'notifications' => 'r,u',
'reports-income-summary' => 'r',
'reports-expense-summary' => 'r',
'reports-income-summary' => 'r',
'reports-income-expense-summary' => 'r',
'reports-profit-loss' => 'r',
'reports-tax-summary' => 'r',
'settings-appearance' => 'r,u',
'settings-categories' => 'c,r,u,d',
'settings-company' => 'r',
'settings-currencies' => 'c,r,u,d',
'settings-defaults' => 'r',
'settings-email' => 'r',
'settings-invoice' => 'r',
'settings-localisation' => 'r',
'settings-modules' => 'r,u',
'settings-settings' => 'r,u',
'settings-schedule' => 'r',
'settings-taxes' => 'c,r,u,d',
'wizard-companies' => 'c,r,u',
'wizard-currencies' => 'c,r,u',
'wizard-taxes' => 'c,r,u',
'wizard-finish' => 'c,r,u',
'wizard-taxes' => 'c,r,u',
],
'manager' => [
'admin-panel' => 'r',
'auth-profile' => 'r,u',
'banking-accounts' => 'c,r,u,d',
'banking-reconciliations' => 'c,r,u,d',
'banking-transactions' => 'c,r,u,d',
'banking-transfers' => 'c,r,u,d',
'common-companies' => 'c,r,u,d',
'common-import' => 'c',
'common-items' => 'c,r,u,d',
'common-uploads' => 'r',
'common-notifications' => 'c,r,u,d',
'incomes-invoices' => 'c,r,u,d',
'incomes-revenues' => 'c,r,u,d',
'incomes-customers' => 'c,r,u,d',
'common-reports' => 'c,r,u,d',
'common-search' => 'r',
'common-uploads' => 'r',
'common-widgets' => 'r',
'expenses-bills' => 'c,r,u,d',
'expenses-payments' => 'c,r,u,d',
'expenses-vendors' => 'c,r,u,d',
'banking-accounts' => 'c,r,u,d',
'banking-transfers' => 'c,r,u,d',
'banking-transactions' => 'r',
'banking-reconciliations' => 'c,r,u,d',
'settings-settings' => 'r,u',
'settings-categories' => 'c,r,u,d',
'settings-taxes' => 'c,r,u,d',
'settings-currencies' => 'c,r,u,d',
'settings-modules' => 'r,u',
'incomes-customers' => 'c,r,u,d',
'incomes-invoices' => 'c,r,u,d',
'incomes-revenues' => 'c,r,u,d',
'install-updates' => 'r,u',
'notifications' => 'r,u',
'reports-income-summary' => 'r',
'reports-expense-summary' => 'r',
'reports-income-summary' => 'r',
'reports-income-expense-summary' => 'r',
'reports-profit-loss' => 'r',
'reports-tax-summary' => 'r',
'settings-categories' => 'c,r,u,d',
'settings-company' => 'r',
'settings-currencies' => 'c,r,u,d',
'settings-defaults' => 'r',
'settings-email' => 'r',
'settings-invoice' => 'r',
'settings-localisation' => 'r',
'settings-modules' => 'r,u',
'settings-settings' => 'r,u',
'settings-schedule' => 'r',
'settings-taxes' => 'c,r,u,d',
],
'customer' => [
'customer-panel' => 'r',
'customers-invoices' => 'r,u',
'customers-payments' => 'r,u',
'customers-transactions' => 'r',
'customers-profile' => 'r,u',
'client-portal' => 'r',
'portal-invoices' => 'r,u',
'portal-payments' => 'r,u',
'portal-transactions' => 'r',
'portal-profile' => 'r,u',
],
];

View File

@ -2,7 +2,7 @@
namespace Database\Seeds;
use App\Models\Model;
use App\Abstracts\Model;
use Illuminate\Database\Seeder;
use Date;
@ -29,36 +29,33 @@ class Settings extends Seeder
setting()->setExtraColumns(['company_id' => $company_id]);
setting()->set([
'general.financial_start' => Date::now()->startOfYear()->format('d-m'),
'general.timezone' => 'Europe/London',
'general.date_format' => 'd M Y',
'general.date_separator' => 'space',
'general.percent_position' => 'after',
'general.invoice_number_prefix' => 'INV-',
'general.invoice_number_digit' => '5',
'general.invoice_number_next' => '1',
'general.default_payment_method' => 'offlinepayment.cash.1',
'general.email_protocol' => 'mail',
'general.email_sendmail_path' => '/usr/sbin/sendmail -bs',
'general.send_invoice_reminder' => '0',
'general.schedule_invoice_days' => '1,3,5,10',
'general.send_bill_reminder' => '0',
'general.schedule_bill_days' => '10,5,3,1',
'general.send_item_reminder' => '0',
'general.schedule_item_stocks' => '3,5,7',
'general.schedule_time' => '09:00',
'general.admin_theme' => 'skin-green-light',
'general.list_limit' => '25',
'general.use_gravatar' => '0',
'general.session_handler' => 'file',
'general.session_lifetime' => '30',
'general.file_size' => '2',
'general.file_types' => 'pdf,jpeg,jpg,png',
'general.wizard' => '0',
'general.invoice_item' => 'settings.invoice.item',
'general.invoice_price' => 'settings.invoice.price',
'general.invoice_quantity' => 'settings.invoice.quantity',
'offlinepayment.methods' => '[{"code":"offlinepayment.cash.1","name":"Cash","order":"1","description":null},{"code":"offlinepayment.bank_transfer.2","name":"Bank Transfer","order":"2","description":null}]',
'localisation.financial_start' => Date::now()->startOfYear()->format('d-m'),
'localisation.timezone' => 'Europe/London',
'localisation.date_format' => 'd M Y',
'localisation.date_separator' => 'space',
'localisation.percent_position' => 'after',
'invoice.number_prefix' => 'INV-',
'invoice.number_digit' => '5',
'invoice.number_next' => '1',
'invoice.item_name' => 'settings.invoice.item',
'invoice.price_name' => 'settings.invoice.price',
'invoice.quantity_name' => 'settings.invoice.quantity',
'invoice.title' => trans_choice('general.invoices', 1),
'invoice.payment_terms' => '0',
'default.payment_method' => 'offline-payments.cash.1',
'default.list_limit' => '25',
'default.use_gravatar' => '0',
'email.protocol' => 'mail',
'email.sendmail_path' => '/usr/sbin/sendmail -bs',
'schedule.send_invoice_reminder' => '0',
'schedule.invoice_days' => '1,3,5,10',
'schedule.send_bill_reminder' => '0',
'schedule.bill_days' => '10,5,3,1',
'schedule.time' => '09:00',
'wizard.completed' => '0',
'offline-payments.methods' => '[{"code":"offline-payments.cash.1","name":"Cash","order":"1","description":null},{"code":"offline-payments.bank_transfer.2","name":"Bank Transfer","order":"2","description":null}]',
'contact.type.customer' => 'customer',
'contact.type.vendor' => 'vendor',
]);
}
}

View File

@ -2,7 +2,7 @@
namespace Database\Seeds;
use App\Models\Model;
use App\Abstracts\Model;
use App\Models\Auth\User;
use App\Models\Common\Company;
use Date;
@ -43,17 +43,17 @@ class TestCompany extends Seeder
setting()->setExtraColumns(['company_id' => '1']);
setting()->set([
'general.company_name' => 'Test Inc.',
'general.company_email' => 'info@test.com',
'general.company_address' => 'New Street 1254',
'general.financial_start' => '01-01',
'general.default_currency' => 'USD',
'general.default_account' => '1',
'general.default_payment_method' => 'offlinepayment.cash.1',
'general.schedule_bill_days' => '10,5,3,1',
'general.schedule_invoice_days' => '1,3,5,10',
'general.send_invoice_reminder' => true,
'general.send_bill_reminder' => true,
'company.name' => 'Test Inc.',
'company.email' => 'info@test.com',
'company.address' => 'New Street 1254',
'localisation.financial_start' => '01-01',
'default.currency' => 'USD',
'default.account' => '1',
'default.payment_method' => 'offline-paymentz.cash.1',
'schedule.bill_days' => '10,5,3,1',
'schedule.invoice_days' => '1,3,5,10',
'schedule.send_invoice_reminder' => true,
'schedule.send_bill_reminder' => true,
]);
setting()->save();

View File

@ -0,0 +1,17 @@
<?php
use Illuminate\Database\Seeder;
class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->call(Database\Seeds\Widgets::class);
$this->call(Database\Seeds\Dashboards::class);
}
}

View File

@ -0,0 +1,99 @@
<?php
namespace Database\Seeds;
use App\Abstracts\Model;
use App\Models\Common\Widget;
use Illuminate\Database\Seeder;
class Widgets extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->create();
Model::reguard();
}
private function create()
{
$company_id = $this->command->argument('company');
$rows = [
[
'company_id' => $company_id,
'name' => trans('dashboard.total_incomes'),
'alias' => 'total-incomes',
'settings' => ['width'=>'col-md-4'],
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('dashboard.total_expenses'),
'alias' => 'total-expenses',
'settings' => ['width'=>'col-md-4'],
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('dashboard.total_profit'),
'alias' => 'total-profit',
'settings' => ['width'=>'col-md-4'],
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('dashboard.cash_flow'),
'alias' => 'cash-flow',
'settings' => ['width'=>'col-md-12'],
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('dashboard.incomes_by_category'),
'alias' => 'incomes-by-category',
'settings' => ['width'=>'col-md-6'],
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('dashboard.expenses_by_category'),
'alias' => 'expenses-by-category',
'settings' => ['width'=>'col-md-6'],
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('dashboard.account_balance'),
'alias' => 'account-balance',
'settings' => ['width'=>'col-md-4'],
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('dashboard.latest_incomes'),
'alias' => 'latest-incomes',
'settings' => ['width'=>'col-md-4'],
'enabled' => 1,
],
[
'company_id' => $company_id,
'name' => trans('dashboard.latest_expenses'),
'alias' => 'latest-expenses',
'settings' => ['width'=>'col-md-4'],
'enabled' => 1,
]
];
foreach ($rows as $row) {
Widget::create($row);
}
}
}