Merge pull request #4126 from turbo124/v2

Laravel 8 support
This commit is contained in:
David Bomba 2020-10-01 21:47:07 +10:00 committed by GitHub
commit 15320500c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
87 changed files with 2778 additions and 1552 deletions

View File

@ -48,6 +48,7 @@ REQUIRE_HTTPS=false
GOOGLE_MAPS_API_KEY= GOOGLE_MAPS_API_KEY=
API_SECRET=superdoopersecrethere API_SECRET=superdoopersecrethere
ERROR_EMAIL= ERROR_EMAIL=
TRUSTED_PROXIES=
NINJA_ENVIRONMENT=selfhost NINJA_ENVIRONMENT=selfhost

View File

@ -27,12 +27,19 @@ use App\Helpers\Invoice\InvoiceSum;
use App\Jobs\Quote\CreateQuoteInvitations; use App\Jobs\Quote\CreateQuoteInvitations;
use App\Listeners\Credit\CreateCreditInvitation; use App\Listeners\Credit\CreateCreditInvitation;
use App\Listeners\Invoice\CreateInvoiceInvitation; use App\Listeners\Invoice\CreateInvoiceInvitation;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\CompanyToken; use App\Models\CompanyToken;
use App\Models\Country; use App\Models\Country;
use App\Models\Expense;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\Product; use App\Models\Product;
use App\Models\Project;
use App\Models\Task;
use App\Models\User; use App\Models\User;
use App\Models\Vendor;
use App\Models\VendorContact;
use App\Repositories\InvoiceRepository; use App\Repositories\InvoiceRepository;
use App\Utils\Ninja; use App\Utils\Ninja;
use App\Utils\Traits\GeneratesCounter; use App\Utils\Traits\GeneratesCounter;
@ -93,8 +100,8 @@ class CreateTestData extends Command
{ {
$this->info('Creating Small Account and Company'); $this->info('Creating Small Account and Company');
$account = factory(\App\Models\Account::class)->create(); $account = Account::factory()->create();
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'slack_webhook_url' => config('ninja.notification.slack'), 'slack_webhook_url' => config('ninja.notification.slack'),
]); ]);
@ -105,7 +112,7 @@ class CreateTestData extends Command
$user = User::whereEmail('small@example.com')->first(); $user = User::whereEmail('small@example.com')->first();
if (! $user) { if (! $user) {
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'email' => 'small@example.com', 'email' => 'small@example.com',
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
@ -132,7 +139,7 @@ class CreateTestData extends Command
'settings' => null, 'settings' => null,
]); ]);
factory(\App\Models\Product::class, 50)->create([ Product::factory()->count(50)->create([
'user_id' => $user->id, 'user_id' => $user->id,
'company_id' => $company->id, 'company_id' => $company->id,
]); ]);
@ -188,8 +195,8 @@ class CreateTestData extends Command
{ {
$this->info('Creating Medium Account and Company'); $this->info('Creating Medium Account and Company');
$account = factory(\App\Models\Account::class)->create(); $account = Account::factory()->create();
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'slack_webhook_url' => config('ninja.notification.slack'), 'slack_webhook_url' => config('ninja.notification.slack'),
]); ]);
@ -200,7 +207,7 @@ class CreateTestData extends Command
$user = User::whereEmail('medium@example.com')->first(); $user = User::whereEmail('medium@example.com')->first();
if (! $user) { if (! $user) {
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'email' => 'medium@example.com', 'email' => 'medium@example.com',
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
@ -226,7 +233,7 @@ class CreateTestData extends Command
'settings' => null, 'settings' => null,
]); ]);
factory(\App\Models\Product::class, 50)->create([ Product::factory()->count(50)->create([
'user_id' => $user->id, 'user_id' => $user->id,
'company_id' => $company->id, 'company_id' => $company->id,
]); ]);
@ -284,8 +291,8 @@ class CreateTestData extends Command
{ {
$this->info('Creating Large Account and Company'); $this->info('Creating Large Account and Company');
$account = factory(\App\Models\Account::class)->create(); $account = Account::factory()->create();
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'slack_webhook_url' => config('ninja.notification.slack'), 'slack_webhook_url' => config('ninja.notification.slack'),
'is_large' => true, 'is_large' => true,
@ -297,7 +304,7 @@ class CreateTestData extends Command
$user = User::whereEmail('large@example.com')->first(); $user = User::whereEmail('large@example.com')->first();
if (! $user) { if (! $user) {
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'email' => 'large@example.com', 'email' => 'large@example.com',
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
@ -323,7 +330,7 @@ class CreateTestData extends Command
'settings' => null, 'settings' => null,
]); ]);
factory(\App\Models\Product::class, 15000)->create([ Product::factory()->count(15000)->create([
'user_id' => $user->id, 'user_id' => $user->id,
'company_id' => $company->id, 'company_id' => $company->id,
]); ]);
@ -383,19 +390,19 @@ class CreateTestData extends Command
// dispatch(function () use ($company, $user) { // dispatch(function () use ($company, $user) {
// }); // });
$client = factory(\App\Models\Client::class)->create([ $client = Client::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'company_id' => $company->id, 'company_id' => $company->id,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $company->id, 'company_id' => $company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, rand(1, 5))->create([ ClientContact::factory()->count(rand(1, 5))->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $company->id, 'company_id' => $company->id,
@ -415,7 +422,7 @@ class CreateTestData extends Command
private function createExpense($client) private function createExpense($client)
{ {
factory(\App\Models\Expense::class, rand(1, 5))->create([ Expense::factory()->count(rand(1, 5))->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $client->company->id, 'company_id' => $client->company->id,
@ -424,19 +431,19 @@ class CreateTestData extends Command
private function createVendor($client) private function createVendor($client)
{ {
$vendor = factory(\App\Models\Vendor::class)->create([ $vendor = Vendor::factory()->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'company_id' => $client->company->id, 'company_id' => $client->company->id,
]); ]);
factory(\App\Models\VendorContact::class, 1)->create([ VendorContact::factory()->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'vendor_id' => $vendor->id, 'vendor_id' => $vendor->id,
'company_id' => $client->company->id, 'company_id' => $client->company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\VendorContact::class, rand(1, 5))->create([ VendorContact::factory()->count(rand(1, 5))->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'vendor_id' => $vendor->id, 'vendor_id' => $vendor->id,
'company_id' => $client->company->id, 'company_id' => $client->company->id,
@ -446,7 +453,7 @@ class CreateTestData extends Command
private function createTask($client) private function createTask($client)
{ {
$vendor = factory(\App\Models\Task::class)->create([ $vendor = Task::factory()->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'company_id' => $client->company->id, 'company_id' => $client->company->id,
]); ]);
@ -454,7 +461,7 @@ class CreateTestData extends Command
private function createProject($client) private function createProject($client)
{ {
$vendor = factory(\App\Models\Project::class)->create([ $vendor = Project::factory()->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'company_id' => $client->company->id, 'company_id' => $client->company->id,
]); ]);
@ -520,7 +527,7 @@ class CreateTestData extends Command
// } // }
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
$credit = factory(\App\Models\Credit::class)->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]); $credit = Credit::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
$dateable = Carbon::now()->subDays(rand(0, 90)); $dateable = Carbon::now()->subDays(rand(0, 90));
$credit->date = $dateable; $credit->date = $dateable;
@ -564,7 +571,7 @@ class CreateTestData extends Command
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
//$quote = QuoteFactory::create($client->company->id, $client->user->id);//stub the company and user_id //$quote = QuoteFactory::create($client->company->id, $client->user->id);//stub the company and user_id
$quote = factory(\App\Models\Quote::class)->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]); $quote = Quote::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
$quote->date = $faker->date(); $quote->date = $faker->date();
$quote->client_id = $client->id; $quote->client_id = $client->id;

View File

@ -18,10 +18,21 @@ use App\Factory\InvoiceItemFactory;
use App\Helpers\Invoice\InvoiceSum; use App\Helpers\Invoice\InvoiceSum;
use App\Jobs\Ninja\CompanySizeCheck; use App\Jobs\Ninja\CompanySizeCheck;
use App\Jobs\Util\VersionCheck; use App\Jobs\Util\VersionCheck;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Company;
use App\Models\CompanyToken; use App\Models\CompanyToken;
use App\Models\Country; use App\Models\Country;
use App\Models\Credit;
use App\Models\Expense;
use App\Models\Product; use App\Models\Product;
use App\Models\Project;
use App\Models\Quote;
use App\Models\Task;
use App\Models\User; use App\Models\User;
use App\Models\Vendor;
use App\Models\VendorContact;
use App\Repositories\InvoiceRepository; use App\Repositories\InvoiceRepository;
use App\Utils\Ninja; use App\Utils\Ninja;
use App\Utils\Traits\GeneratesCounter; use App\Utils\Traits\GeneratesCounter;
@ -30,8 +41,8 @@ use Carbon\Carbon;
use Composer\Composer; use Composer\Composer;
use Composer\Console\Application; use Composer\Console\Application;
use Composer\Factory; use Composer\Factory;
use Composer\Installer;
use Composer\IO\NullIO; use Composer\IO\NullIO;
use Composer\Installer;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
@ -125,8 +136,8 @@ class DemoMode extends Command
$this->info('Creating Small Account and Company'); $this->info('Creating Small Account and Company');
$account = factory(\App\Models\Account::class)->create(); $account = Account::factory()->create();
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'slack_webhook_url' => config('ninja.notification.slack'), 'slack_webhook_url' => config('ninja.notification.slack'),
'enabled_modules' => 32767, 'enabled_modules' => 32767,
@ -155,7 +166,7 @@ class DemoMode extends Command
$user = User::whereEmail('small@example.com')->first(); $user = User::whereEmail('small@example.com')->first();
if (! $user) { if (! $user) {
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'email' => 'small@example.com', 'email' => 'small@example.com',
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
@ -185,7 +196,7 @@ class DemoMode extends Command
$u2 = User::where('email', 'demo@invoiceninja.com')->first(); $u2 = User::where('email', 'demo@invoiceninja.com')->first();
if (! $u2) { if (! $u2) {
$u2 = factory(\App\Models\User::class)->create([ $u2 = User::factory()->create([
'email' => 'demo@invoiceninja.com', 'email' => 'demo@invoiceninja.com',
'password' => Hash::make('demo'), 'password' => Hash::make('demo'),
'account_id' => $account->id, 'account_id' => $account->id,
@ -211,7 +222,7 @@ class DemoMode extends Command
]); ]);
} }
factory(\App\Models\Product::class, 50)->create([ Product::factory()->count(50)->create([
'user_id' => $user->id, 'user_id' => $user->id,
'company_id' => $company->id, 'company_id' => $company->id,
]); ]);
@ -277,19 +288,19 @@ class DemoMode extends Command
// dispatch(function () use ($company, $user) { // dispatch(function () use ($company, $user) {
// }); // });
$client = factory(\App\Models\Client::class)->create([ $client = Client::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'company_id' => $company->id, 'company_id' => $company->id,
]); ]);
factory(\App\Models\ClientContact::class)->create([ ClientContact::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $company->id, 'company_id' => $company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, rand(1, 5))->create([ ClientContact::factory()->count(rand(1,5))->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $company->id, 'company_id' => $company->id,
@ -311,7 +322,7 @@ class DemoMode extends Command
private function createExpense($client) private function createExpense($client)
{ {
factory(\App\Models\Expense::class, rand(1, 5))->create([ Expense::factory()->count(rand(1,5))->create([
'user_id' => $client->user_id, 'user_id' => $client->user_id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $client->company_id, 'company_id' => $client->company_id,
@ -320,19 +331,19 @@ class DemoMode extends Command
private function createVendor($client, $assigned_user_id = null) private function createVendor($client, $assigned_user_id = null)
{ {
$vendor = factory(\App\Models\Vendor::class)->create([ $vendor = Vendor::factory()->create([
'user_id' => $client->user_id, 'user_id' => $client->user_id,
'company_id' => $client->company_id, 'company_id' => $client->company_id,
]); ]);
factory(\App\Models\VendorContact::class)->create([ VendorContact::factory()->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'vendor_id' => $vendor->id, 'vendor_id' => $vendor->id,
'company_id' => $client->company_id, 'company_id' => $client->company_id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\VendorContact::class, rand(1, 5))->create([ VendorContact::factory()->count(rand(1,5))->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'vendor_id' => $vendor->id, 'vendor_id' => $vendor->id,
'company_id' => $client->company_id, 'company_id' => $client->company_id,
@ -342,7 +353,7 @@ class DemoMode extends Command
private function createTask($client, $assigned_user_id = null) private function createTask($client, $assigned_user_id = null)
{ {
$vendor = factory(\App\Models\Task::class)->create([ $vendor = Task::factory()->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'company_id' => $client->company_id, 'company_id' => $client->company_id,
]); ]);
@ -350,7 +361,7 @@ class DemoMode extends Command
private function createProject($client, $assigned_user_id = null) private function createProject($client, $assigned_user_id = null)
{ {
$vendor = factory(\App\Models\Project::class)->create([ $vendor = Project::factory()->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'company_id' => $client->company_id, 'company_id' => $client->company_id,
]); ]);
@ -430,7 +441,7 @@ class DemoMode extends Command
// } // }
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
$credit = factory(\App\Models\Credit::class)->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]); $credit = Credit::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
if ((bool) rand(0, 1)) { if ((bool) rand(0, 1)) {
$dateable = Carbon::now()->subDays(rand(0, 90)); $dateable = Carbon::now()->subDays(rand(0, 90));
@ -478,7 +489,7 @@ class DemoMode extends Command
{ {
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
$quote = factory(\App\Models\Quote::class)->create(['user_id' => $client->user->id, 'company_id' => $client->company_id, 'client_id' => $client->id]); $quote = Quote::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company_id, 'client_id' => $client->id]);
if ((bool) rand(0, 1)) { if ((bool) rand(0, 1)) {
$dateable = Carbon::now()->subDays(rand(1, 30)); $dateable = Carbon::now()->subDays(rand(1, 30));

View File

@ -78,7 +78,7 @@ class ImportMigrations extends Command
$account = $this->getAccount(); $account = $this->getAccount();
$company = $this->getCompany($account); $company = $this->getCompany($account);
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'email' => $this->faker->email, 'email' => $this->faker->email,
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
@ -107,7 +107,7 @@ class ImportMigrations extends Command
public function getAccount(): Account public function getAccount(): Account
{ {
return factory(\App\Models\Account::class)->create(); return Account::factory()->create();
} }
public function getCompany(Account $account): Company public function getCompany(Account $account): Company

View File

@ -20,8 +20,10 @@ use App\Factory\InvoiceInvitationFactory;
use App\Helpers\Email\InvoiceEmail; use App\Helpers\Email\InvoiceEmail;
use App\Jobs\Invoice\CreateInvoicePdf; use App\Jobs\Invoice\CreateInvoicePdf;
use App\Mail\TemplateEmail; use App\Mail\TemplateEmail;
use App\Models\Account;
use App\Models\Client; use App\Models\Client;
use App\Models\ClientContact; use App\Models\ClientContact;
use App\Models\Company;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\User; use App\Models\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@ -80,9 +82,10 @@ class SendTestEmails extends Command
$user = User::whereEmail('user@example.com')->first(); $user = User::whereEmail('user@example.com')->first();
if (! $user) { if (! $user) {
$account = factory(\App\Models\Account::class)->create();
$user = factory(\App\Models\User::class)->create([ $account = Account::factory()->create();
$user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'confirmation_code' => '123', 'confirmation_code' => '123',
'email' => $faker->safeEmail, 'email' => $faker->safeEmail,
@ -90,7 +93,7 @@ class SendTestEmails extends Command
'last_name' => 'Doe', 'last_name' => 'Doe',
]); ]);
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
]); ]);
@ -115,7 +118,7 @@ class SendTestEmails extends Command
$client = ClientFactory::create($company->id, $user->id); $client = ClientFactory::create($company->id, $user->id);
$client->save(); $client->save();
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $company->id, 'company_id' => $company->id,
@ -124,7 +127,7 @@ class SendTestEmails extends Command
'email' => $faker->safeEmail, 'email' => $faker->safeEmail,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $company->id, 'company_id' => $company->id,

View File

@ -56,7 +56,7 @@ class CreateTestCreditJob implements ShouldQueue
{ {
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
$credit = factory(\App\Models\Credit::class)->create(['user_id' => $this->client->user->id, 'company_id' => $this->client->company->id, 'client_id' => $this->client->id]); $credit = Credit::factory()->create(['user_id' => $this->client->user->id, 'company_id' => $this->client->company->id, 'client_id' => $this->client->id]);
//$invoice = InvoiceFactory::create($this->client->company->id, $this->client->user->id);//stub the company and user_id //$invoice = InvoiceFactory::create($this->client->company->id, $this->client->user->id);//stub the company and user_id
//$invoice->client_id = $this->client->id; //$invoice->client_id = $this->client->id;

View File

@ -55,7 +55,7 @@ class CreateTestQuoteJob implements ShouldQueue
{ {
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
$quote = factory(\App\Models\Quote::class)->create(['user_id' => $this->client->user->id, 'company_id' => $this->client->company->id, 'client_id' => $this->client->id]); $quote = Quote::factory()->create(['user_id' => $this->client->user->id, 'company_id' => $this->client->company->id, 'client_id' => $this->client->id]);
$quote->date = $faker->date(); $quote->date = $faker->date();
$quote->line_items = $this->buildLineItems(rand(1, 10)); $quote->line_items = $this->buildLineItems(rand(1, 10));

View File

@ -585,11 +585,11 @@ class CompanySettings extends BaseSettings
'$quote.total', '$quote.total',
], ],
'credit_details' => [ 'credit_details' => [
'$credit.credit_number', '$credit.number',
'$credit.po_number', '$credit.po_number',
'$credit.credit_date', '$credit.date',
'$credit.credit_balance', '$credit.balance',
'$credit.credit_amount', '$credit.total',
], ],
'product_columns' => [ 'product_columns' => [
'$product.product_key', '$product.product_key',

View File

@ -332,11 +332,11 @@ class Designer
private function creditDetails(Company $company) private function creditDetails(Company $company)
{ {
$data = [ $data = [
'$credit.credit_number' => '<span class="flex justify-between items-center">$credit.number_label<span></span><span>$credit.number</span></span>', '$credit.number' => '<span class="flex justify-between items-center">$credit.number_label<span></span><span>$credit.number</span></span>',
'$credit.po_number' => '<span class="flex justify-between items-center">$credit.po_number_label<span></span><span>$credit.po_number</span></span>', '$credit.po_number' => '<span class="flex justify-between items-center">$credit.po_number_label<span></span><span>$credit.po_number</span></span>',
'$credit.credit_date' => '<span class="flex justify-between items-center">$credit.date_label<span></span><span>$credit.date</span></span>', '$credit.date' => '<span class="flex justify-between items-center">$credit.date_label<span></span><span>$credit.date</span></span>',
'$credit.credit_balance' => '<span class="flex justify-between items-center">$credit.balance_label<span></span><span>$credit.balance</span></span>', '$credit.balance' => '<span class="flex justify-between items-center">$credit.balance_label<span></span><span>$credit.balance</span></span>',
'$credit.credit_amount' => '<span class="flex justify-between items-center">$credit.amount_label<span></span><span>$credit.amount</span></span>', '$credit.total' => '<span class="flex justify-between items-center">$credit.total_label<span></span><span>$credit.total</span></span>',
'$credit.partial_due' => '<span class="flex justify-between items-center">$credit.partial_due_label<span></span><span>$credit.partial_due</span></span>', '$credit.partial_due' => '<span class="flex justify-between items-center">$credit.partial_due_label<span></span><span>$credit.partial_due</span></span>',
'$credit.custom1' => '<span class="flex justify-between items-center">$credit.custom1_label<span></span><span>$credit.custom1</span></span>', '$credit.custom1' => '<span class="flex justify-between items-center">$credit.custom1_label<span></span><span>$credit.custom1</span></span>',
'$credit.custom2' => '<span class="flex justify-between items-center">$credit.custom2_label<span></span><span>$credit.custom2</span></span>', '$credit.custom2' => '<span class="flex justify-between items-center">$credit.custom2_label<span></span><span>$credit.custom2</span></span>',

View File

@ -32,6 +32,7 @@ use App\Jobs\Invoice\CreateInvoicePdf;
use App\Jobs\Invoice\EmailInvoice; use App\Jobs\Invoice\EmailInvoice;
use App\Jobs\Invoice\StoreInvoice; use App\Jobs\Invoice\StoreInvoice;
use App\Jobs\Invoice\ZipInvoices; use App\Jobs\Invoice\ZipInvoices;
use App\Jobs\Util\UnlinkFile;
use App\Models\Client; use App\Models\Client;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\InvoiceInvitation; use App\Models\InvoiceInvitation;
@ -391,6 +392,8 @@ class InvoiceController extends BaseController
$invoice = $this->invoice_repo->save($request->all(), $invoice); $invoice = $this->invoice_repo->save($request->all(), $invoice);
UnlinkFile::dispatchNow(config('filesystems.default'),$invoice->client->invoice_filepath().$invoice->number.'.pdf');
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars())); event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars()));
return $this->itemResponse($invoice); return $this->itemResponse($invoice);

View File

@ -132,12 +132,12 @@ class PreviewController extends BaseController
{ {
DB::beginTransaction(); DB::beginTransaction();
$client = factory(\App\Models\Client::class)->create([ $client = Client::factory()->create([
'user_id' => auth()->user()->id, 'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id, 'company_id' => auth()->user()->company()->id,
]); ]);
$contact = factory(\App\Models\ClientContact::class)->create([ $contact = ClientContact::factory()->create([
'user_id' => auth()->user()->id, 'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id, 'company_id' => auth()->user()->company()->id,
'client_id' => $client->id, 'client_id' => $client->id,
@ -145,13 +145,13 @@ class PreviewController extends BaseController
'send_email' => true, 'send_email' => true,
]); ]);
$invoice = factory(\App\Models\Invoice::class)->create([ $invoice = Invoice::factory()->create([
'user_id' => auth()->user()->id, 'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id, 'company_id' => auth()->user()->company()->id,
'client_id' => $client->id, 'client_id' => $client->id,
]); ]);
$invitation = factory(\App\Models\InvoiceInvitation::class)->create([ $invitation = InvoiceInvitation::factory()->create([
'user_id' => auth()->user()->id, 'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id, 'company_id' => auth()->user()->company()->id,
'invoice_id' => $invoice->id, 'invoice_id' => $invoice->id,

View File

@ -12,16 +12,21 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
use App\Models\Client;
use App\Models\ClientContact; use App\Models\ClientContact;
use App\Models\CompanyToken; use App\Models\CompanyToken;
use Closure;
use Auth; use Auth;
use Closure;
class ContactKeyLogin class ContactKeyLogin
{ {
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* Sets a contact LOGGED IN if an appropriate client_hash is provided as a query parameter
* OR
* If the contact_key is provided in the route
*
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return mixed * @return mixed
@ -47,6 +52,25 @@ class ContactKeyLogin
return redirect()->to('client/dashboard'); return redirect()->to('client/dashboard');
} }
}
else if($request->has('client_hash') && config('ninja.db.multi_db_enabled')){
if (MultiDB::findAndSetDbByClientHash($request->input('client_hash'))) {
$client = Client::where('client_hash', $request->input('client_hash'))->first();
Auth::guard('contact')->login($client->primary_contact()->first(), true);
return redirect()->to('client/dashboard');
}
}
else if($request->has('client_hash')){
if($client = Client::where('client_hash', $request->input('client_hash'))->first()){
Auth::guard('contact')->login($client->primary_contact()->first(), true);
return redirect()->to('client/dashboard');
}
} }
return $next($request); return $next($request);

View File

@ -13,6 +13,7 @@ namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware; use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Contracts\Config\Repository;
class TrustProxies extends Middleware class TrustProxies extends Middleware
{ {
@ -29,4 +30,18 @@ class TrustProxies extends Middleware
* @var int * @var int
*/ */
protected $headers = Request::HEADER_X_FORWARDED_ALL; protected $headers = Request::HEADER_X_FORWARDED_ALL;
/*
* Instantiate trusted proxies middleware
*
* @param \Illuminate\Contracts\Config\Repository $config
*/
public function __construct(Repository $config) {
parent::__construct($config);
if (config('ninja.trusted_proxies'))
$this->proxies = config('ninja.trusted_proxies');
}
} }

View File

@ -100,7 +100,7 @@ class StoreRecurringInvoiceRequest extends Request
if(isset($input['auto_bill'])) if(isset($input['auto_bill']))
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']); $input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
else{ else{
$client = Client::find($this->decodePrimaryKey($input['client_id'])); $client = Client::find($input['client_id']);
$input['auto_bill'] = $client->getSetting('auto_bill'); $input['auto_bill'] = $client->getSetting('auto_bill');
} }

View File

@ -130,7 +130,7 @@ class Import implements ShouldQueue
public $timeout = 86400; public $timeout = 86400;
public $retryAfter = 86430; public $backoff = 86430;
/** /**
* Create a new job instance. * Create a new job instance.

View File

@ -54,7 +54,7 @@ class StartMigration implements ShouldQueue
public $timeout = 86400; public $timeout = 86400;
public $retryAfter = 86430; public $backoff = 86430;
public function __construct($filepath, User $user, Company $company) public function __construct($filepath, User $user, Company $company)
{ {

View File

@ -11,6 +11,7 @@
namespace App\Libraries; namespace App\Libraries;
use App\Models\Client;
use App\Models\ClientContact; use App\Models\ClientContact;
use App\Models\Company; use App\Models\Company;
use App\Models\CompanyToken; use App\Models\CompanyToken;
@ -200,7 +201,6 @@ class MultiDB
foreach (self::$dbs as $db) { foreach (self::$dbs as $db) {
if ($client_contact = ClientContact::on($db)->where('contact_key', $contact_key)->first()) { if ($client_contact = ClientContact::on($db)->where('contact_key', $contact_key)->first()) {
self::setDb($client_contact->company->db); self::setDb($client_contact->company->db);
return true; return true;
} }
} }
@ -208,6 +208,17 @@ class MultiDB
return false; return false;
} }
public static function findAndSetDbByClientHash($client_hash) :bool
{
foreach (self::$dbs as $db) {
if ($client = Client::on($db)->where('client_hash', $client_hash)->first()) {
self::setDb($client->company->db);
return true;
}
}
return false;
}
public static function findAndSetDbByDomain($subdomain) :bool public static function findAndSetDbByDomain($subdomain) :bool
{ {

View File

@ -48,7 +48,7 @@ class DeletedUserActivity implements ShouldQueue
$fields = new \stdClass; $fields = new \stdClass;
if (auth()->user()->id) { if (auth()->check()) {
$fields->user_id = auth()->user()->id; $fields->user_id = auth()->user()->id;
} else { } else {
$fields->user_id = $event->user->id; $fields->user_id = $event->user->id;

View File

@ -70,6 +70,7 @@ class TemplateEmail extends Mailable
'signature' => $settings->email_signature, 'signature' => $settings->email_signature,
'settings' => $settings, 'settings' => $settings,
'company' => $company, 'company' => $company,
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
]); ]);
//conditionally attach files //conditionally attach files

View File

@ -24,11 +24,13 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class BaseModel extends Model class BaseModel extends Model
{ {
use MakesHash; use MakesHash;
use UserSessionAttributes; use UserSessionAttributes;
use HasFactory;
//todo customise names of archived_at / updated_at columns //todo customise names of archived_at / updated_at columns
///const CREATED_AT = 'creation_date'; ///const CREATED_AT = 'creation_date';

View File

@ -14,12 +14,13 @@ namespace App\Models;
use App\Models\Company; use App\Models\Company;
use App\Models\Language; use App\Models\Language;
use App\Models\User; use App\Models\User;
use App\Notifications\ClientContactResetPassword;
use App\Notifications\ClientContactResetPassword as ResetPasswordNotification; use App\Notifications\ClientContactResetPassword as ResetPasswordNotification;
use App\Notifications\ClientContactResetPassword;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Hashids\Hashids; use Hashids\Hashids;
use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Contracts\Translation\HasLocalePreference; use Illuminate\Contracts\Translation\HasLocalePreference;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
@ -33,6 +34,7 @@ class ClientContact extends Authenticatable implements HasLocalePreference
use MakesHash; use MakesHash;
use PresentableTrait; use PresentableTrait;
use SoftDeletes; use SoftDeletes;
use HasFactory;
/* Used to authenticate a contact */ /* Used to authenticate a contact */
protected $guard = 'contact'; protected $guard = 'contact';
@ -198,4 +200,20 @@ class ClientContact extends Authenticatable implements HasLocalePreference
return asset('images/svg/user.svg'); return asset('images/svg/user.svg');
} }
/**
* Provides a convenience login click for contacts to bypass the
* contact authentication layer
*
* @return string URL
*/
public function getLoginLink()
{
$domain = isset($this->company->portal_domain) ?: $this->company->domain();
return $domain . 'client/key_login/' . $this->contact_key;
}
} }

View File

@ -426,7 +426,7 @@ class Company extends BaseModel
public function domain() public function domain()
{ {
if (Ninja::isNinja()) { if (Ninja::isNinja()) {
return $this->subdomain.config('ninja.app_domain'); return $this->subdomain . config('ninja.app_domain');
} }
return config('ninja.app_url'); return config('ninja.app_url');

View File

@ -72,13 +72,15 @@ class Gateway extends StaticModel
$link = 'https://dashboard.stripe.com/account/apikeys'; $link = 'https://dashboard.stripe.com/account/apikeys';
} }
$key = 'texts.gateway_help_'.$this->id; // $key = 'texts.gateway_help_'.$this->id;
$str = trans($key, [ // $str = trans($key, [
'link' => "<a href='$link' >Click here</a>", // 'link' => "<a href='$link' >Click here</a>",
'complete_link' => url('/complete'), // 'complete_link' => url('/complete'),
]); // ]);
return $key != $str ? $str : ''; return $link;
//return $key != $str ? $str : '';
} }
} }

View File

@ -22,6 +22,7 @@ use App\Utils\Traits\UserSessionAttributes;
use App\Utils\Traits\UserSettings; use App\Utils\Traits\UserSettings;
use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Contracts\Translation\HasLocalePreference; use Illuminate\Contracts\Translation\HasLocalePreference;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
@ -40,6 +41,7 @@ class User extends Authenticatable implements MustVerifyEmail
use UserSettings; use UserSettings;
use Filterable; use Filterable;
use \Staudenmeir\EloquentHasManyDeep\HasRelationships; use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
use HasFactory;
protected $guard = 'user'; protected $guard = 'user';

View File

@ -14,12 +14,13 @@ namespace App\Models;
use App\Models\Company; use App\Models\Company;
use App\Models\Language; use App\Models\Language;
use App\Models\User; use App\Models\User;
use App\Notifications\ClientContactResetPassword;
use App\Notifications\ClientContactResetPassword as ResetPasswordNotification; use App\Notifications\ClientContactResetPassword as ResetPasswordNotification;
use App\Notifications\ClientContactResetPassword;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Hashids\Hashids; use Hashids\Hashids;
use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Contracts\Translation\HasLocalePreference; use Illuminate\Contracts\Translation\HasLocalePreference;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
@ -33,6 +34,7 @@ class VendorContact extends Authenticatable implements HasLocalePreference
use MakesHash; use MakesHash;
use PresentableTrait; use PresentableTrait;
use SoftDeletes; use SoftDeletes;
use HasFactory;
/* Used to authenticate a vendor */ /* Used to authenticate a vendor */
protected $guard = 'vendor'; protected $guard = 'vendor';

View File

@ -47,6 +47,7 @@ class ClientContactTransformer extends EntityTransformer
'send_email' => (bool) $contact->send_email, 'send_email' => (bool) $contact->send_email,
'last_login' => (int) $contact->last_login, 'last_login' => (int) $contact->last_login,
'password' => empty($contact->password) ? '' : '**********', 'password' => empty($contact->password) ? '' : '**********',
'link' => $contact->getLoginLink(),
]; ];
} }
} }

View File

@ -16,8 +16,18 @@ use App\Models\Client;
class Helpers class Helpers
{ {
public static function sharedEmailVariables(Client $client, array $settings = null): array public static function sharedEmailVariables(?Client $client, array $settings = null): array
{ {
if(!$client){
$elements['signature'] = '';
$elements['settings'] = new \stdClass;
$elements['whitelabel'] = true;
return $elements;
}
$_settings = is_null($settings) ? $client->getMergedSettings() : $settings; $_settings = is_null($settings) ? $client->getMergedSettings() : $settings;
$elements['signature'] = $_settings->email_signature; $elements['signature'] = $_settings->email_signature;

View File

@ -162,7 +162,7 @@ class HtmlEngine
$data['$quote.amount'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.quote_total')]; $data['$quote.amount'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.quote_total')];
$data['$credit.total'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.credit_total')]; $data['$credit.total'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.credit_total')];
$data['$credit.number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.credit_number')]; $data['$credit.number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.credit_number')];
$data['$credit.amount'] = &$data['$credit.total']; $data['$credit.total'] = &$data['$credit.total'];
$data['$credit.po_number'] = &$data['$invoice.po_number']; $data['$credit.po_number'] = &$data['$invoice.po_number'];
$data['$credit.date'] = ['value' => $this->entity->date, 'label' => ctrans('texts.credit_date')]; $data['$credit.date'] = ['value' => $this->entity->date, 'label' => ctrans('texts.credit_date')];
$data['$balance'] = ['value' => Number::formatMoney($this->entity_calc->getBalance(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.balance')]; $data['$balance'] = ['value' => Number::formatMoney($this->entity_calc->getBalance(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.balance')];

View File

@ -253,7 +253,7 @@ trait MakesInvoiceValues
$data['$quote.amount'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.quote_total')]; $data['$quote.amount'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.quote_total')];
$data['$credit.total'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.credit_total')]; $data['$credit.total'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.credit_total')];
$data['$credit.number'] = ['value' => $this->number ?: '&nbsp;', 'label' => ctrans('texts.credit_number')]; $data['$credit.number'] = ['value' => $this->number ?: '&nbsp;', 'label' => ctrans('texts.credit_number')];
$data['$credit.amount'] = &$data['$credit.total']; $data['$credit.total'] = &$data['$credit.total'];
$data['$credit.po_number'] = &$data['$invoice.po_number']; $data['$credit.po_number'] = &$data['$invoice.po_number'];
$data['$credit.date'] = ['value' => $this->date, 'label' => ctrans('texts.credit_date')]; $data['$credit.date'] = ['value' => $this->date, 'label' => ctrans('texts.credit_date')];
$data['$balance'] = ['value' => Number::formatMoney($calc->getBalance(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.balance')]; $data['$balance'] = ['value' => Number::formatMoney($calc->getBalance(), $this->client) ?: '&nbsp;', 'label' => ctrans('texts.balance')];

View File

@ -96,7 +96,7 @@ trait MakesTemplateData
$data['$quote_total'] = ['value' => '$100.00', 'label' => ctrans('texts.quote_total')]; $data['$quote_total'] = ['value' => '$100.00', 'label' => ctrans('texts.quote_total')];
$data['$quote.amount'] = &$data['$quote_total']; $data['$quote.amount'] = &$data['$quote_total'];
$data['$credit_total'] = ['value' => '$100.00', 'label' => ctrans('texts.credit_total')]; $data['$credit_total'] = ['value' => '$100.00', 'label' => ctrans('texts.credit_total')];
$data['$credit.amount'] = &$data['$credit_total']; $data['$credit.total'] = &$data['$credit_total'];
$data['$balance'] = ['value' => '$100.00', 'label' => ctrans('texts.balance')]; $data['$balance'] = ['value' => '$100.00', 'label' => ctrans('texts.balance')];
$data['$invoice.balance'] = &$data['$balance']; $data['$invoice.balance'] = &$data['$balance'];
$data['$taxes'] = ['value' => '$10.00', 'label' => ctrans('texts.taxes')]; $data['$taxes'] = ['value' => '$10.00', 'label' => ctrans('texts.taxes')];

View File

@ -53,8 +53,12 @@ trait HasRecurrence
*/ */
public function setDayOfMonth($date, $day_of_month) public function setDayOfMonth($date, $day_of_month)
{ {
info($date);
$carbon_date = Carbon::parse($date); $carbon_date = Carbon::parse($date);
info($carbon_date);
$set_date = $carbon_date->copy()->setUnitNoOverflow('day', $day_of_month, 'month'); $set_date = $carbon_date->copy()->setUnitNoOverflow('day', $day_of_month, 'month');
//If the set date is less than the original date we need to add a month. //If the set date is less than the original date we need to add a month.

View File

@ -3,7 +3,13 @@
"description": "Invoices, expenses & time-tracking built with Laravel", "description": "Invoices, expenses & time-tracking built with Laravel",
"keywords": [ "keywords": [
"invoice", "invoice",
"laravel" "laravel",
"invoicing",
"time tracking",
"expenses",
"CRM",
"Credit card billing",
"projects"
], ],
"license": "Attribution Assurance License", "license": "Attribution Assurance License",
"authors": [ "authors": [
@ -26,19 +32,19 @@
"cleverit/ubl_invoice": "^1.3", "cleverit/ubl_invoice": "^1.3",
"composer/composer": "^1.10", "composer/composer": "^1.10",
"czproject/git-php": "^3.17", "czproject/git-php": "^3.17",
"dacastro4/laravel-gmail": "^4.0", "turbo124/laravel-gmail": "^5.0",
"doctrine/dbal": "^2.10", "doctrine/dbal": "^2.10",
"fedeisas/laravel-mail-css-inliner": "^3", "fedeisas/laravel-mail-css-inliner": "^3",
"fideloper/proxy": "^4.2", "fideloper/proxy": "^4.2",
"fzaninotto/faker": "^1.4", "fzaninotto/faker": "^1.4",
"google/apiclient": "^2.7", "google/apiclient": "^2.7",
"guzzlehttp/guzzle": "^6.5", "guzzlehttp/guzzle": "^7.0.1",
"hashids/hashids": "^3.0", "hashids/hashids": "^3.0",
"intervention/image": "^2.5", "intervention/image": "^2.5",
"laracasts/presenter": "^0.2.1", "laracasts/presenter": "^0.2.1",
"laravel/framework": "^7.27", "laravel/framework": "^8.0",
"laravel/slack-notification-channel": "^2.2", "laravel/slack-notification-channel": "^2.2",
"laravel/socialite": "^4.4", "laravel/socialite": "^5",
"laravel/tinker": "^2.0", "laravel/tinker": "^2.0",
"league/flysystem-aws-s3-v3": "~1.0", "league/flysystem-aws-s3-v3": "~1.0",
"league/flysystem-cached-adapter": "^1.1", "league/flysystem-cached-adapter": "^1.1",
@ -49,33 +55,31 @@
"nwidart/laravel-modules": "^6.0", "nwidart/laravel-modules": "^6.0",
"omnipay/paypal": "^3.0", "omnipay/paypal": "^3.0",
"predis/predis": "^1.1", "predis/predis": "^1.1",
"sentry/sentry-laravel": "^1.8", "sentry/sentry-laravel": "^2",
"spatie/browsershot": "^3.37", "spatie/browsershot": "^3.37",
"staudenmeir/eloquent-has-many-deep": "^1.11", "staudenmeir/eloquent-has-many-deep": "^1.11",
"stripe/stripe-php": "^7.50", "stripe/stripe-php": "^7.50",
"turbo124/beacon": "^1", "turbo124/beacon": "^1",
"webpatser/laravel-countries": "dev-master#75992ad", "webpatser/laravel-countries": "dev-master#75992ad",
"laravel/ui": "^2.0" "laravel/ui": "^3.0"
}, },
"require-dev": { "require-dev": {
"wildbit/postmark-php": "^2.6", "wildbit/postmark-php": "^4.0",
"anahkiasen/former": "^4.2", "anahkiasen/former": "^4.2",
"barryvdh/laravel-debugbar": "^3.4", "barryvdh/laravel-debugbar": "^3.4",
"darkaonline/l5-swagger": "^7.0", "darkaonline/l5-swagger": "^8.0",
"filp/whoops": "^2.7", "filp/whoops": "^2.7",
"mockery/mockery": "^1.3.1", "mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1", "nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^8.5", "phpunit/phpunit": "^9.0",
"fzaninotto/faker": "^1.9.1", "fzaninotto/faker": "^1.9.1",
"facade/ignition": "^2.0" "facade/ignition": "^2.3.6"
}, },
"autoload": { "autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": { "psr-4": {
"App\\": "app/" "App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}, },
"files": [ "files": [
"app/Libraries/OFX.php" "app/Libraries/OFX.php"

2009
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,7 @@ return [
'enabled_modules' => 32767, 'enabled_modules' => 32767,
'phantomjs_key' => env('PHANTOMJS_KEY', false), 'phantomjs_key' => env('PHANTOMJS_KEY', false),
'phantomjs_secret' => env('PHANTOMJS_SECRET', false), 'phantomjs_secret' => env('PHANTOMJS_SECRET', false),
'trusted_proxies' => env('TRUSTED_PROXIES', false),
'sentry_dsn' => env('SENTRY_LARAVEL_DSN', 'https://9b4e15e575214354a7d666489783904a@sentry.invoicing.co/6'), 'sentry_dsn' => env('SENTRY_LARAVEL_DSN', 'https://9b4e15e575214354a7d666489783904a@sentry.invoicing.co/6'),
'environment' => env('NINJA_ENVIRONMENT', 'selfhost'), // 'hosted', 'development', 'selfhost', 'reseller' 'environment' => env('NINJA_ENVIRONMENT', 'selfhost'), // 'hosted', 'development', 'selfhost', 'reseller'

View File

@ -1,12 +1,40 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use Faker\Generator as Faker; use App\Models\Account;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str; use Illuminate\Support\Str;
$factory->define(App\Models\Account::class, function (Faker $faker) { class AccountFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Account::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'default_company_id' => 1, 'default_company_id' => 1,
'key' => Str::random(32), 'key' => Str::random(32),
'report_errors' => 1, 'report_errors' => 1,
]; ];
}); }
}

View File

@ -1,28 +1,48 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use Faker\Generator as Faker; use App\Models\Account;
use App\Models\ClientContact;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/* class ClientContactFactory extends Factory
|-------------------------------------------------------------------------- {
| Model Factories /**
|-------------------------------------------------------------------------- * The name of the factory's corresponding model.
| *
| This directory should contain each of the model factory definitions for * @var string
| your application. Factories provide a convenient way to generate new */
| model instances for testing / seeding your application's database. protected $model = ClientContact::class;
|
*/
$factory->define(App\Models\ClientContact::class, function (Faker $faker) { /**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'first_name' => $faker->firstName, 'first_name' => $this->faker->firstName,
'last_name' => $faker->lastName, 'last_name' => $this->faker->lastName,
'phone' => $faker->phoneNumber, 'phone' => $this->faker->phoneNumber,
'email_verified_at' => now(), 'email_verified_at' => now(),
'email' => $faker->unique()->safeEmail, 'email' => $this->faker->unique()->safeEmail,
'send_email' => true, 'send_email' => true,
'password' => bcrypt('password'), 'password' => bcrypt('password'),
'remember_token' => \Illuminate\Support\Str::random(10), 'remember_token' => \Illuminate\Support\Str::random(10),
'contact_key' => \Illuminate\Support\Str::random(40), 'contact_key' => \Illuminate\Support\Str::random(40),
]; ];
}); }
}

View File

@ -1,35 +1,64 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings; use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings; use App\Models\Client;
use Faker\Generator as Faker; use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class ClientFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Client::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$factory->define(App\Models\Client::class, function (Faker $faker) {
return [ return [
'name' => $faker->company(), 'name' => $this->faker->company(),
'website' => $faker->url, 'website' => $this->faker->url,
'private_notes' => $faker->text(200), 'private_notes' => $this->faker->text(200),
'balance' => 0, 'balance' => 0,
'paid_to_date' => 0, 'paid_to_date' => 0,
'vat_number' => $faker->numberBetween(123456789, 987654321), 'vat_number' => $this->faker->numberBetween(123456789, 987654321),
'id_number' => '', 'id_number' => '',
'custom_value1' => '', 'custom_value1' => '',
'custom_value2' => '', 'custom_value2' => '',
'custom_value3' => '', 'custom_value3' => '',
'custom_value4' => '', 'custom_value4' => '',
'address1' => $faker->buildingNumber, 'address1' => $this->faker->buildingNumber,
'address2' => $faker->streetAddress, 'address2' => $this->faker->streetAddress,
'city' => $faker->city, 'city' => $this->faker->city,
'state' => $faker->state, 'state' => $this->faker->state,
'postal_code' => $faker->postcode, 'postal_code' => $this->faker->postcode,
'country_id' => 4, 'country_id' => 4,
'shipping_address1' => $faker->buildingNumber, 'shipping_address1' => $this->faker->buildingNumber,
'shipping_address2' => $faker->streetAddress, 'shipping_address2' => $this->faker->streetAddress,
'shipping_city' => $faker->city, 'shipping_city' => $this->faker->city,
'shipping_state' => $faker->state, 'shipping_state' => $this->faker->state,
'shipping_postal_code' => $faker->postcode, 'shipping_postal_code' => $this->faker->postcode,
'shipping_country_id' => 4, 'shipping_country_id' => 4,
'settings' => ClientSettings::defaults(), 'settings' => ClientSettings::defaults(),
'client_hash' => \Illuminate\Support\Str::random(40), 'client_hash' => \Illuminate\Support\Str::random(40),
]; ];
}); }
}

View File

@ -1,18 +0,0 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\Models\ClientLocation::class, function (Faker $faker) {
return [
'address1' => $faker->buildingNumber,
'address2' => $faker->streetAddress,
'city' => $faker->city,
'state' => $faker->state,
'postal_code' => $faker->postcode,
'country_id' => 4,
'latitude' => $faker->latitude,
'longitude' => $faker->longitude,
'description' => $faker->paragraph,
'private_notes' => $faker->paragraph,
];
});

View File

@ -1,13 +1,41 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
use Faker\Generator as Faker; use App\Models\Company;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
$factory->define(App\Models\Company::class, function (Faker $faker) { class CompanyFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Company::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
//'name' => $faker->name, //'name' => $this->faker->name,
'company_key' => strtolower(\Illuminate\Support\Str::random(config('ninja.key_length'))), 'company_key' => strtolower(\Illuminate\Support\Str::random(config('ninja.key_length'))),
'ip' => $faker->ipv4, 'ip' => $this->faker->ipv4,
'db' => config('database.default'), 'db' => config('database.default'),
'settings' => CompanySettings::defaults(), 'settings' => CompanySettings::defaults(),
'is_large' => false, 'is_large' => false,
@ -26,4 +54,5 @@ $factory->define(App\Models\Company::class, function (Faker $faker) {
// 'company4'=>'4', // 'company4'=>'4',
], ],
]; ];
}); }
}

View File

@ -1,14 +1,42 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings; use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
use App\Factory\InvoiceItemFactory; use App\Factory\InvoiceItemFactory;
use Faker\Generator as Faker; use App\Models\Credit;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
$factory->define(App\Models\Credit::class, function (Faker $faker) { class CreditFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Credit::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'status_id' => App\Models\Credit::STATUS_DRAFT, 'status_id' => Credit::STATUS_DRAFT,
'discount' => $faker->numberBetween(1, 10), 'discount' => $this->faker->numberBetween(1, 10),
'is_amount_discount' => (bool) random_int(0, 1), 'is_amount_discount' => (bool) random_int(0, 1),
'tax_name1' => 'GST', 'tax_name1' => 'GST',
'tax_rate1' => 10, 'tax_rate1' => 10,
@ -16,15 +44,16 @@ $factory->define(App\Models\Credit::class, function (Faker $faker) {
'tax_rate2' => 17.5, 'tax_rate2' => 17.5,
//'tax_name3' => 'THIRDTAX', //'tax_name3' => 'THIRDTAX',
//'tax_rate3' => 5, //'tax_rate3' => 5,
// 'custom_value1' => $faker->numberBetween(1,4), // 'custom_value1' => $this->faker->numberBetween(1,4),
// 'custom_value2' => $faker->numberBetween(1,4), // 'custom_value2' => $this->faker->numberBetween(1,4),
// 'custom_value3' => $faker->numberBetween(1,4), // 'custom_value3' => $this->faker->numberBetween(1,4),
// 'custom_value4' => $faker->numberBetween(1,4), // 'custom_value4' => $this->faker->numberBetween(1,4),
'is_deleted' => false, 'is_deleted' => false,
'po_number' => $faker->text(10), 'po_number' => $this->faker->text(10),
'date' => $faker->date(), 'date' => $this->faker->date(),
'due_date' => $faker->date(), 'due_date' => $this->faker->date(),
'line_items' => InvoiceItemFactory::generateCredit(5), 'line_items' => InvoiceItemFactory::generateCredit(5),
'terms' => $faker->text(500), 'terms' => $this->faker->text(500),
]; ];
}); }
}

View File

@ -1,22 +1,47 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings; use App\Models\Expense;
use App\DataMapper\CompanySettings; use Illuminate\Database\Eloquent\Factories\Factory;
use App\Factory\InvoiceItemFactory; use Illuminate\Support\Str;
use Faker\Generator as Faker;
$factory->define(App\Models\Expense::class, function (Faker $faker) { class ExpenseFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Expense::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'amount' => $faker->numberBetween(1, 10), 'amount' => $this->faker->numberBetween(1, 10),
'custom_value1' => $faker->text(10), 'custom_value1' => $this->faker->text(10),
'custom_value2' => $faker->text(10), 'custom_value2' => $this->faker->text(10),
'custom_value3' => $faker->text(10), 'custom_value3' => $this->faker->text(10),
'custom_value4' => $faker->text(10), 'custom_value4' => $this->faker->text(10),
'exchange_rate' => $faker->randomFloat(2, 0, 1), 'exchange_rate' => $this->faker->randomFloat(2, 0, 1),
'expense_date' => $faker->date(), 'expense_date' => $this->faker->date(),
'is_deleted' => false, 'is_deleted' => false,
'public_notes' => $faker->text(50), 'public_notes' => $this->faker->text(50),
'private_notes' => $faker->text(50), 'private_notes' => $this->faker->text(50),
'transaction_reference' => $faker->text(5), 'transaction_reference' => $this->faker->text(5),
]; ];
}); }
}

View File

@ -1,8 +1,35 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use Faker\Generator as Faker; use App\Models\Gateway;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
$factory->define(App\Models\Gateway::class, function (Faker $faker) { class GatewayFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Gateway::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'key' => '3b6621f970ab18887c4f6dca78d3f8bb', 'key' => '3b6621f970ab18887c4f6dca78d3f8bb',
'visible' => true, 'visible' => true,
@ -14,4 +41,5 @@ $factory->define(App\Models\Gateway::class, function (Faker $faker) {
'fields' => '', 'fields' => '',
'default_gateway_type_id' => 1, 'default_gateway_type_id' => 1,
]; ];
}); }
}

View File

@ -1,15 +1,43 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings; use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
use App\Factory\InvoiceItemFactory; use App\Factory\InvoiceItemFactory;
use Faker\Generator as Faker; use App\Models\Invoice;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
$factory->define(App\Models\Invoice::class, function (Faker $faker) { class InvoiceFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Invoice::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'status_id' => App\Models\Invoice::STATUS_SENT, 'status_id' => Invoice::STATUS_SENT,
'number' => $faker->ean13(), 'number' => $this->faker->ean13(),
'discount' => $faker->numberBetween(1, 10), 'discount' => $this->faker->numberBetween(1, 10),
'is_amount_discount' => (bool) random_int(0, 1), 'is_amount_discount' => (bool) random_int(0, 1),
'tax_name1' => 'GST', 'tax_name1' => 'GST',
'tax_rate1' => 10, 'tax_rate1' => 10,
@ -17,15 +45,16 @@ $factory->define(App\Models\Invoice::class, function (Faker $faker) {
'tax_rate2' => 17.5, 'tax_rate2' => 17.5,
//'tax_name3' => 'THIRDTAX', //'tax_name3' => 'THIRDTAX',
//'tax_rate3' => 5, //'tax_rate3' => 5,
'custom_value1' => $faker->date, 'custom_value1' => $this->faker->date,
'custom_value2' => rand(0, 1) ? 'yes' : 'no', 'custom_value2' => rand(0, 1) ? 'yes' : 'no',
// 'custom_value3' => $faker->numberBetween(1,4), // 'custom_value3' => $this->faker->numberBetween(1,4),
// 'custom_value4' => $faker->numberBetween(1,4), // 'custom_value4' => $this->faker->numberBetween(1,4),
'is_deleted' => false, 'is_deleted' => false,
'po_number' => $faker->text(10), 'po_number' => $this->faker->text(10),
'date' => $faker->date(), 'date' => $this->faker->date(),
'due_date' => $faker->date(), 'due_date' => $this->faker->date(),
'line_items' => InvoiceItemFactory::generate(5), 'line_items' => InvoiceItemFactory::generate(5),
'terms' => $faker->text(500), 'terms' => $this->faker->text(500),
]; ];
}); }
}

View File

@ -1,10 +1,37 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use Faker\Generator as Faker; use App\Models\InvoiceInvitation;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str; use Illuminate\Support\Str;
$factory->define(App\Models\InvoiceInvitation::class, function (Faker $faker) { class InvoiceInvitationFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = InvoiceInvitation::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'key' => Str::random(40), 'key' => Str::random(40),
]; ];
}); }
}

View File

@ -1,17 +1,44 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use App\Models\Payment; use App\Models\Payment;
use Faker\Generator as Faker; use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
$factory->define(App\Models\Payment::class, function (Faker $faker) { class PaymentFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Payment::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'is_deleted' => false, 'is_deleted' => false,
'amount' => $faker->numberBetween(1, 10), 'amount' => $this->faker->numberBetween(1, 10),
'date' => $faker->date(), 'date' => $this->faker->date(),
'transaction_reference' => $faker->text(10), 'transaction_reference' => $this->faker->text(10),
'type_id' => Payment::TYPE_CREDIT_CARD, 'type_id' => Payment::TYPE_CREDIT_CARD,
'status_id' => Payment::STATUS_COMPLETED, 'status_id' => Payment::STATUS_COMPLETED,
]; ];
}); }
}

View File

@ -1,24 +1,53 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use Faker\Generator as Faker;
$factory->define(App\Models\Product::class, function (Faker $faker) { use App\Models\Product;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class ProductFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Product::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'product_key' => $faker->text(7), 'product_key' => $this->faker->text(7),
'notes' => $faker->text(20), 'notes' => $this->faker->text(20),
'cost' => $faker->numberBetween(1, 1000), 'cost' => $this->faker->numberBetween(1, 1000),
'price' => $faker->numberBetween(1, 1000), 'price' => $this->faker->numberBetween(1, 1000),
'quantity' => $faker->numberBetween(1, 100), 'quantity' => $this->faker->numberBetween(1, 100),
'tax_name1' => 'GST', 'tax_name1' => 'GST',
'tax_rate1' => 10, 'tax_rate1' => 10,
'tax_name2' => 'VAT', 'tax_name2' => 'VAT',
'tax_rate2' => 17.5, 'tax_rate2' => 17.5,
'tax_name3' => 'THIRDTAX', 'tax_name3' => 'THIRDTAX',
'tax_rate3' => 5, 'tax_rate3' => 5,
'custom_value1' => $faker->text(20), 'custom_value1' => $this->faker->text(20),
'custom_value2' => $faker->text(20), 'custom_value2' => $this->faker->text(20),
'custom_value3' => $faker->text(20), 'custom_value3' => $this->faker->text(20),
'custom_value4' => $faker->text(20), 'custom_value4' => $this->faker->text(20),
'is_deleted' => false, 'is_deleted' => false,
]; ];
}); }
}

View File

@ -1,12 +1,40 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use Faker\Generator as Faker;
$factory->define(App\Models\Project::class, function (Faker $faker) {
use App\Models\Project;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class ProjectFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Project::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'name' => $faker->name(), 'name' => $this->faker->name(),
'description' => $faker->text(50), 'description' => $this->faker->text(50),
]; ];
}); }
}

View File

@ -1,26 +1,53 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use Faker\Generator as Faker;
$factory->define(App\Models\Quote::class, function (Faker $faker) { use App\Models\Quote;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class QuoteFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Quote::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'status_id' => App\Models\Quote::STATUS_DRAFT, 'status_id' => Quote::STATUS_DRAFT,
'discount' => $faker->numberBetween(1, 10), 'discount' => $this->faker->numberBetween(1, 10),
'is_amount_discount' => $faker->boolean(), 'is_amount_discount' => $this->faker->boolean(),
'tax_name1' => 'GST', 'tax_name1' => 'GST',
'tax_rate1' => 10, 'tax_rate1' => 10,
'tax_name2' => 'VAT', 'tax_name2' => 'VAT',
'tax_rate2' => 17.5, 'tax_rate2' => 17.5,
'tax_name3' => 'THIRDTAX', 'tax_name3' => 'THIRDTAX',
'tax_rate3' => 5, 'tax_rate3' => 5,
// 'custom_value1' => $faker->numberBetween(1, 4), // 'custom_value1' => $this->faker->numberBetween(1, 4),
// 'custom_value2' => $faker->numberBetween(1, 4), // 'custom_value2' => $this->faker->numberBetween(1, 4),
// 'custom_value3' => $faker->numberBetween(1, 4), // 'custom_value3' => $this->faker->numberBetween(1, 4),
// 'custom_value4' => $faker->numberBetween(1, 4), // 'custom_value4' => $this->faker->numberBetween(1, 4),
'is_deleted' => false, 'is_deleted' => false,
'po_number' => $faker->text(10), 'po_number' => $this->faker->text(10),
'line_items' => false, 'line_items' => false,
]; ];
}); }
}

View File

@ -1,10 +1,38 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use Faker\Generator as Faker;
use App\Models\QuoteInvitation;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str; use Illuminate\Support\Str;
$factory->define(App\Models\QuoteInvitation::class, function (Faker $faker) { class QuoteInvitationFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = QuoteInvitation::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'key' => Str::random(40), 'key' => Str::random(40),
]; ];
}); }
}

View File

@ -1,34 +1,61 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use Faker\Generator as Faker;
$factory->define(App\Models\RecurringInvoice::class, function (Faker $faker) { use App\Models\RecurringInvoice;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class RecurringInvoiceFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = RecurringInvoice::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'status_id' => App\Models\RecurringInvoice::STATUS_ACTIVE, 'status_id' => RecurringInvoice::STATUS_ACTIVE,
'discount' => $faker->numberBetween(1, 10), 'discount' => $this->faker->numberBetween(1, 10),
'is_amount_discount' => $faker->boolean(), 'is_amount_discount' => $this->faker->boolean(),
'tax_name1' => 'GST', 'tax_name1' => 'GST',
'tax_rate1' => 10, 'tax_rate1' => 10,
'tax_name2' => 'VAT', 'tax_name2' => 'VAT',
'tax_rate2' => 17.5, 'tax_rate2' => 17.5,
'tax_name3' => 'THIRDTAX', 'tax_name3' => 'THIRDTAX',
'tax_rate3' => 5, 'tax_rate3' => 5,
'custom_value1' => $faker->numberBetween(1, 4), 'custom_value1' => $this->faker->numberBetween(1, 4),
'custom_value2' => $faker->numberBetween(1, 4), 'custom_value2' => $this->faker->numberBetween(1, 4),
'custom_value3' => $faker->numberBetween(1, 4), 'custom_value3' => $this->faker->numberBetween(1, 4),
'custom_value4' => $faker->numberBetween(1, 4), 'custom_value4' => $this->faker->numberBetween(1, 4),
'is_deleted' => false, 'is_deleted' => false,
'po_number' => $faker->text(10), 'po_number' => $this->faker->text(10),
'date' => $faker->date(), 'date' => $this->faker->date(),
'due_date' => $faker->date(), 'due_date' => $this->faker->date(),
'line_items' => false, 'line_items' => false,
'frequency_id' => App\Models\RecurringInvoice::FREQUENCY_MONTHLY, 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY,
'last_sent_date' => now()->subMonth(), 'last_sent_date' => now()->subMonth(),
'next_send_date' => now()->addMonthNoOverflow(), 'next_send_date' => now()->addMonthNoOverflow(),
'remaining_cycles' => $faker->numberBetween(1, 10), 'remaining_cycles' => $this->faker->numberBetween(1, 10),
'amount' => $faker->randomFloat(2, $min = 1, $max = 1000), // 48.8932 'amount' => $this->faker->randomFloat(2, $min = 1, $max = 1000), // 48.8932
]; ];
}); }
}

View File

@ -1,34 +1,61 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings; use App\Models\QuoteInvitation;
use App\DataMapper\CompanySettings; use App\Models\RecurringQuote;
use Faker\Generator as Faker; use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
$factory->define(App\Models\RecurringQuote::class, function (Faker $faker) { class RecurringQuoteFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = RecurringQuote::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'status_id' => App\Models\RecurringQuote::STATUS_DRAFT, 'status_id' => RecurringQuote::STATUS_DRAFT,
'number' => $faker->text(256), 'number' => $this->faker->text(256),
'discount' => $faker->numberBetween(1, 10), 'discount' => $this->faker->numberBetween(1, 10),
'is_amount_discount' => $faker->boolean(), 'is_amount_discount' => $this->faker->boolean(),
'tax_name1' => 'GST', 'tax_name1' => 'GST',
'tax_rate1' => 10, 'tax_rate1' => 10,
'tax_name2' => 'VAT', 'tax_name2' => 'VAT',
'tax_rate2' => 17.5, 'tax_rate2' => 17.5,
'tax_name3' => 'THIRDTAX', 'tax_name3' => 'THIRDTAX',
'tax_rate3' => 5, 'tax_rate3' => 5,
'custom_value1' => $faker->numberBetween(1, 4), 'custom_value1' => $this->faker->numberBetween(1, 4),
'custom_value2' => $faker->numberBetween(1, 4), 'custom_value2' => $this->faker->numberBetween(1, 4),
'custom_value3' => $faker->numberBetween(1, 4), 'custom_value3' => $this->faker->numberBetween(1, 4),
'custom_value4' => $faker->numberBetween(1, 4), 'custom_value4' => $this->faker->numberBetween(1, 4),
'is_deleted' => false, 'is_deleted' => false,
'po_number' => $faker->text(10), 'po_number' => $this->faker->text(10),
'date' => $faker->date(), 'date' => $this->faker->date(),
'due_date' => $faker->date(), 'due_date' => $this->faker->date(),
'line_items' => false, 'line_items' => false,
'frequency_id' => App\Models\RecurringQuote::FREQUENCY_MONTHLY, 'frequency_id' => RecurringQuote::FREQUENCY_MONTHLY,
'start_date' => $faker->date(), 'start_date' => $this->faker->date(),
'last_sent_date' => $faker->date(), 'last_sent_date' => $this->faker->date(),
'next_send_date' => $faker->date(), 'next_send_date' => $this->faker->date(),
'remaining_cycles' => $faker->numberBetween(1, 10), 'remaining_cycles' => $this->faker->numberBetween(1, 10),
]; ];
}); }
}

View File

@ -1,11 +1,38 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use Faker\Generator as Faker;
$factory->define(App\Models\Task::class, function (Faker $faker) { use App\Models\Task;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class TaskFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Task::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'description' => $faker->text(50), 'description' => $this->faker->text(50),
]; ];
}); }
}

View File

@ -1,26 +1,44 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use Faker\Generator as Faker;
/* use App\Models\User;
|-------------------------------------------------------------------------- use Illuminate\Database\Eloquent\Factories\Factory;
| Model Factories use Illuminate\Support\Str;
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
$factory->define(App\Models\User::class, function (Faker $faker) { class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'first_name' => $faker->name, 'first_name' => $this->faker->name,
'last_name' => $faker->name, 'last_name' => $this->faker->name,
'phone' => $faker->phoneNumber, 'phone' => $this->faker->phoneNumber,
'email' => config('ninja.testvars.username'), 'email' => config('ninja.testvars.username'),
'email_verified_at' => now(), 'email_verified_at' => now(),
'password' => bcrypt(config('ninja.testvars.password')), // secret 'password' => bcrypt(config('ninja.testvars.password')), // secret
'remember_token' => \Illuminate\Support\Str::random(10), 'remember_token' => \Illuminate\Support\Str::random(10),
]; ];
}); }
}

View File

@ -1,23 +1,41 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use Faker\Generator as Faker;
/* use App\Models\VendorContact;
|-------------------------------------------------------------------------- use Illuminate\Database\Eloquent\Factories\Factory;
| Model Factories use Illuminate\Support\Str;
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
$factory->define(App\Models\VendorContact::class, function (Faker $faker) { class VendorContactFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = VendorContact::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'first_name' => $faker->firstName, 'first_name' => $this->faker->firstName,
'last_name' => $faker->lastName, 'last_name' => $this->faker->lastName,
'phone' => $faker->phoneNumber, 'phone' => $this->faker->phoneNumber,
'email' => $faker->unique()->safeEmail, 'email' => $this->faker->unique()->safeEmail,
]; ];
}); }
}

View File

@ -1,23 +1,51 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Factories;
use Faker\Generator as Faker; use App\Models\Vendor;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
$factory->define(App\Models\Vendor::class, function (Faker $faker) { class VendorFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Vendor::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'name' => $faker->name(), 'name' => $this->faker->name(),
'website' => $faker->url, 'website' => $this->faker->url,
'private_notes' => $faker->text(200), 'private_notes' => $this->faker->text(200),
'vat_number' => $faker->text(25), 'vat_number' => $this->faker->text(25),
'id_number' => $faker->text(20), 'id_number' => $this->faker->text(20),
'custom_value1' => $faker->text(20), 'custom_value1' => $this->faker->text(20),
'custom_value2' => $faker->text(20), 'custom_value2' => $this->faker->text(20),
'custom_value3' => $faker->text(20), 'custom_value3' => $this->faker->text(20),
'custom_value4' => $faker->text(20), 'custom_value4' => $this->faker->text(20),
'address1' => $faker->buildingNumber, 'address1' => $this->faker->buildingNumber,
'address2' => $faker->streetAddress, 'address2' => $this->faker->streetAddress,
'city' => $faker->city, 'city' => $this->faker->city,
'state' => $faker->state, 'state' => $this->faker->state,
'postal_code' => $faker->postcode, 'postal_code' => $this->faker->postcode,
'country_id' => 4, 'country_id' => 4,
]; ];
}); }
}

View File

@ -17,8 +17,11 @@ class UpdateGatewayTableVisibleColumn extends Migration
Gateway::query()->update(['visible' => 0]); Gateway::query()->update(['visible' => 0]);
Gateway::whereIn('id', [1,15,20,39])->update(['visible' => 1]); Gateway::whereIn('id', [1,15,20,39])->update(['visible' => 1]);
} }
/** /**
* Reverse the migrations. * Reverse the migrations.
* *

View File

@ -1,13 +1,24 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Bank; use App\Models\Bank;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class BanksSeeder extends Seeder class BanksSeeder extends Seeder
{ {
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
$this->createBanks(); $this->createBanks();
} }
@ -22,7 +33,7 @@ class BanksSeeder extends Seeder
$banks = json_decode($banks); $banks = json_decode($banks);
foreach ($banks as $bank) { foreach ($banks as $bank) {
if (! DB::table('banks')->where('remote_id', '=', $bank->id)->count()) { if (! \DB::table('banks')->where('remote_id', '=', $bank->id)->count()) {
if (! isset($bank->fid) || ! isset($bank->org)) { if (! isset($bank->fid) || ! isset($bank->org)) {
continue; continue;
} }

View File

@ -1,4 +1,15 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\PaymentLibrary; use App\Models\PaymentLibrary;
use App\Models\Size; use App\Models\Size;

View File

@ -1,7 +1,19 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Country; use App\Models\Country;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Webpatser\Countries\Countries;
class CountriesSeeder extends Seeder class CountriesSeeder extends Seeder
{ {
@ -12,9 +24,10 @@ class CountriesSeeder extends Seeder
*/ */
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
$countries = Countries::getList(); $countries_object = new Countries;
$countries = $countries_object->getList();
foreach ($countries as $countryId => $country) { foreach ($countries as $countryId => $country) {
if ($record = Country::whereCountryCode($country['country-code'])->first()) { if ($record = Country::whereCountryCode($country['country-code'])->first()) {

View File

@ -1,13 +1,25 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Currency; use App\Models\Currency;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class CurrenciesSeeder extends Seeder class CurrenciesSeeder extends Seeder
{ {
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
// http://www.localeplanet.com/icu/currency.html // http://www.localeplanet.com/icu/currency.html
$currencies = [ $currencies = [

View File

@ -0,0 +1,63 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Timezone;
use Database\Seeders\BanksSeeder;
use Database\Seeders\ConstantsSeeder;
use Database\Seeders\CountriesSeeder;
use Database\Seeders\CurrenciesSeeder;
use Database\Seeders\DateFormatsSeeder;
use Database\Seeders\DesignSeeder;
use Database\Seeders\GatewayTypesSeeder;
use Database\Seeders\IndustrySeeder;
use Database\Seeders\LanguageSeeder;
use Database\Seeders\PaymentLibrariesSeeder;
use Database\Seeders\PaymentTypesSeeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->command->info('Running DatabaseSeeder');
if (Timezone::count()) {
$this->command->info('Skipping: already run');
return;
}
Model::unguard();
$this->call([
ConstantsSeeder::class,
PaymentLibrariesSeeder::class,
BanksSeeder::class,
CurrenciesSeeder::class,
LanguageSeeder::class,
CountriesSeeder::class,
IndustrySeeder::class,
PaymentTypesSeeder::class,
GatewayTypesSeeder::class,
DateFormatsSeeder::class,
DesignSeeder::class,
]);
}
}

View File

@ -1,14 +1,26 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\DateFormat; use App\Models\DateFormat;
use App\Models\DatetimeFormat; use App\Models\DatetimeFormat;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class DateFormatsSeeder extends Seeder class DateFormatsSeeder extends Seeder
{ {
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
// Date formats // Date formats
$formats = [ $formats = [

View File

@ -1,15 +1,27 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Bank; use App\Models\Bank;
use App\Models\Design; use App\Models\Design;
use App\Services\PdfMaker\Design as PdfMakerDesign; use App\Services\PdfMaker\Design as PdfMakerDesign;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class DesignSeeder extends Seeder class DesignSeeder extends Seeder
{ {
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
$this->createDesigns(); $this->createDesigns();
} }

View File

@ -1,13 +1,25 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\GatewayType; use App\Models\GatewayType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class GatewayTypesSeeder extends Seeder class GatewayTypesSeeder extends Seeder
{ {
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
$gateway_types = [ $gateway_types = [
['id' => 1, 'alias' => 'credit_card', 'name' => 'Credit Card'], ['id' => 1, 'alias' => 'credit_card', 'name' => 'Credit Card'],

View File

@ -1,13 +1,25 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Industry; use App\Models\Industry;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class IndustrySeeder extends Seeder class IndustrySeeder extends Seeder
{ {
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
$industries = [ $industries = [
['id' => 1, 'name' => 'Accounting & Legal'], ['id' => 1, 'name' => 'Accounting & Legal'],
@ -52,6 +64,5 @@ class IndustrySeeder extends Seeder
} }
} }
Eloquent::reguard();
} }
} }

View File

@ -1,13 +1,25 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Language; use App\Models\Language;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class LanguageSeeder extends Seeder class LanguageSeeder extends Seeder
{ {
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
// https://github.com/caouecs/Laravel-lang // https://github.com/caouecs/Laravel-lang
// https://www.loc.gov/standards/iso639-2/php/code_list.php // https://www.loc.gov/standards/iso639-2/php/code_list.php
@ -53,6 +65,5 @@ class LanguageSeeder extends Seeder
} }
} }
Eloquent::reguard();
} }
} }

View File

@ -1,14 +1,26 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Gateway; use App\Models\Gateway;
use App\Models\GatewayType; use App\Models\GatewayType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class PaymentLibrariesSeeder extends Seeder class PaymentLibrariesSeeder extends Seeder
{ {
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
$gateways = [ $gateways = [
['id' => 1, 'name' => 'Authorize.Net', 'provider' => 'Authorize', 'sort_order' => 5, 'key' => '3b6621f970ab18887c4f6dca78d3f8bb', 'fields' => '{"apiLoginId":"","transactionKey":"","testMode":false,"developerMode":false,"liveEndpoint":"https:\/\/api2.authorize.net\/xml\/v1\/request.api","developerEndpoint":"https:\/\/apitest.authorize.net\/xml\/v1\/request.api"} ['id' => 1, 'name' => 'Authorize.Net', 'provider' => 'Authorize', 'sort_order' => 5, 'key' => '3b6621f970ab18887c4f6dca78d3f8bb', 'fields' => '{"apiLoginId":"","transactionKey":"","testMode":false,"developerMode":false,"liveEndpoint":"https:\/\/api2.authorize.net\/xml\/v1\/request.api","developerEndpoint":"https:\/\/apitest.authorize.net\/xml\/v1\/request.api"}
@ -81,5 +93,16 @@ class PaymentLibrariesSeeder extends Seeder
Gateway::create($gateway); Gateway::create($gateway);
} }
} }
Gateway::query()->update(['visible' => 0]);
Gateway::whereIn('id', [1,15,20,39])->update(['visible' => 1]);
Gateway::all()->each(function ($gateway){
$gateway->site_url = $gateway->getHelp();
$gateway->save();
});
} }
} }

View File

@ -1,13 +1,25 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\PaymentTerm; use App\Models\PaymentTerm;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class PaymentTermsSeeder extends Seeder class PaymentTermsSeeder extends Seeder
{ {
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
$paymentTerms = [ $paymentTerms = [
['num_days' => 0, 'name' => 'Net 0'], ['num_days' => 0, 'name' => 'Net 0'],

View File

@ -1,6 +1,18 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\PaymentType; use App\Models\PaymentType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class PaymentTypesSeeder extends Seeder class PaymentTypesSeeder extends Seeder
@ -22,7 +34,7 @@ class PaymentTypesSeeder extends Seeder
public function run() public function run()
{ {
Eloquent::unguard(); Model::unguard();
$paymentTypes = [ $paymentTypes = [
// ['name' => 'Apply Credit'], // ['name' => 'Apply Credit'],

View File

@ -1,4 +1,14 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\DataMapper\ClientSettings; use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
@ -21,13 +31,16 @@ use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentHash; use App\Models\PaymentHash;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\Product;
use App\Models\Quote; use App\Models\Quote;
use App\Models\RecurringInvoice;
use App\Models\User; use App\Models\User;
use App\Models\UserAccount; use App\Models\UserAccount;
use App\Repositories\CreditRepository; use App\Repositories\CreditRepository;
use App\Repositories\InvoiceRepository; use App\Repositories\InvoiceRepository;
use App\Repositories\QuoteRepository; use App\Repositories\QuoteRepository;
use App\Utils\Ninja; use App\Utils\Ninja;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@ -72,19 +85,19 @@ class RandomDataSeeder extends Seeder
$this->command->info('Running RandomDataSeeder'); $this->command->info('Running RandomDataSeeder');
Eloquent::unguard(); Model::unguard();
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
$account = factory(\App\Models\Account::class)->create(); $account = Account::factory()->create();
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
]); ]);
$account->default_company_id = $company->id; $account->default_company_id = $company->id;
$account->save(); $account->save();
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'email' => $faker->email, 'email' => $faker->email,
'account_id' => $account->id, 'account_id' => $account->id,
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
@ -111,7 +124,7 @@ class RandomDataSeeder extends Seeder
$u2 = User::where('email', 'demo@invoiceninja.com')->first(); $u2 = User::where('email', 'demo@invoiceninja.com')->first();
if (! $u2) { if (! $u2) {
$u2 = factory(\App\Models\User::class)->create([ $u2 = User::factory()->create([
'email' => 'demo@invoiceninja.com', 'email' => 'demo@invoiceninja.com',
'password' => Hash::make('demo'), 'password' => Hash::make('demo'),
'account_id' => $account->id, 'account_id' => $account->id,
@ -137,7 +150,7 @@ class RandomDataSeeder extends Seeder
]); ]);
} }
$client = factory(\App\Models\Client::class)->create([ $client = Client::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'company_id' => $company->id, 'company_id' => $company->id,
]); ]);
@ -155,15 +168,15 @@ class RandomDataSeeder extends Seeder
'contact_key' => \Illuminate\Support\Str::random(40), 'contact_key' => \Illuminate\Support\Str::random(40),
]); ]);
factory(\App\Models\Client::class, 1)->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) { Client::factory()->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) {
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $company->id, 'company_id' => $company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 5)->create([ ClientContact::factory()->count(5)->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $company->id, 'company_id' => $company->id,
@ -171,10 +184,10 @@ class RandomDataSeeder extends Seeder
}); });
/* Product Factory */ /* Product Factory */
factory(\App\Models\Product::class, 2)->create(['user_id' => $user->id, 'company_id' => $company->id]); Product::factory()->count(2)->create(['user_id' => $user->id, 'company_id' => $company->id]);
/* Invoice Factory */ /* Invoice Factory */
factory(\App\Models\Invoice::class, 2)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]); Invoice::factory()->count(2)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
$invoices = Invoice::all(); $invoices = Invoice::all();
$invoice_repo = new InvoiceRepository(); $invoice_repo = new InvoiceRepository();
@ -228,7 +241,7 @@ class RandomDataSeeder extends Seeder
}); });
/*Credits*/ /*Credits*/
factory(\App\Models\Credit::class, 2)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]); Credit::factory()->count(2)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
$credits = Credit::cursor(); $credits = Credit::cursor();
$credit_repo = new CreditRepository(); $credit_repo = new CreditRepository();
@ -253,12 +266,10 @@ class RandomDataSeeder extends Seeder
}); });
/* Recurring Invoice Factory */ /* Recurring Invoice Factory */
factory(\App\Models\RecurringInvoice::class, 1)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]); RecurringInvoice::factory()->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
// factory(\App\Models\Payment::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id, 'settings' => ClientSettings::buildClientSettings($company->settings, $client->settings)]);
/*Credits*/ /*Credits*/
factory(\App\Models\Quote::class, 1)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]); Quote::factory()->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
$quotes = Quote::cursor(); $quotes = Quote::cursor();
$quote_repo = new QuoteRepository(); $quote_repo = new QuoteRepository();

View File

@ -1,4 +1,15 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
use App\DataMapper\DefaultSettings; use App\DataMapper\DefaultSettings;
@ -7,6 +18,7 @@ use App\Models\Client;
use App\Models\ClientContact; use App\Models\ClientContact;
use App\Models\User; use App\Models\User;
use App\Models\UserAccount; use App\Models\UserAccount;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class UsersTableSeeder extends Seeder class UsersTableSeeder extends Seeder
@ -22,12 +34,12 @@ class UsersTableSeeder extends Seeder
{ {
$this->command->info('Running UsersTableSeeder'); $this->command->info('Running UsersTableSeeder');
Eloquent::unguard(); Model::unguard();
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
$account = factory(\App\Models\Account::class)->create(); $account = Account::factory()->create();
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'domain' => 'ninja.test', 'domain' => 'ninja.test',
]); ]);
@ -35,7 +47,7 @@ class UsersTableSeeder extends Seeder
$account->default_company_id = $company->id; $account->default_company_id = $company->id;
$account->save(); $account->save();
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
]); ]);
@ -59,7 +71,7 @@ class UsersTableSeeder extends Seeder
'is_locked' => 0, 'is_locked' => 0,
]); ]);
$client = factory(\App\Models\Client::class)->create([ $client = Client::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'company_id' => $company->id, 'company_id' => $company->id,
]); ]);
@ -74,15 +86,15 @@ class UsersTableSeeder extends Seeder
'client_id' =>$client->id, 'client_id' =>$client->id,
]); ]);
factory(\App\Models\Client::class, 20)->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) { Client::factory()->count(20)->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) {
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $company->id, 'company_id' => $company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 10)->create([ ClientContact::factory()->count(10)->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $company->id, 'company_id' => $company->id,

View File

@ -1,38 +0,0 @@
<?php
use App\Models\Timezone;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->command->info('Running DatabaseSeeder');
if (Timezone::count()) {
$this->command->info('Skipping: already run');
return;
}
Eloquent::unguard();
$this->call('ConstantsSeeder');
$this->call('PaymentLibrariesSeeder');
$this->call('BanksSeeder');
$this->call('CurrenciesSeeder');
$this->call('LanguageSeeder');
$this->call('CountriesSeeder');
$this->call('IndustrySeeder');
//$this->call('PaymentTermsSeeder');
$this->call('PaymentTypesSeeder');
$this->call('GatewayTypesSeeder');
$this->call('DateFormatsSeeder');
$this->call('DesignSeeder');
}
}

View File

@ -1,33 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="true" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
backupStaticAttributes="false" <coverage processUncoveredFiles="true">
bootstrap="vendor/autoload.php" <include>
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="true">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/Integration</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Pdf">
<directory suffix="Test.php">./tests/Pdf</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory> <directory suffix=".php">./app</directory>
</include>
<exclude> <exclude>
<directory suffix=".php">./vendor</directory> <directory suffix=".php">./vendor</directory>
<directory suffix=".php">./app/Providers</directory> <directory suffix=".php">./app/Providers</directory>
@ -52,9 +28,24 @@
<file>./app/Libraries/OFX.php</file> <file>./app/Libraries/OFX.php</file>
<file>./app/Exceptions/Handler.php</file> <file>./app/Exceptions/Handler.php</file>
</exclude> </exclude>
</whitelist> <report>
<clover outputFile="coverage.xml"/>
</filter> </report>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/Integration</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Pdf">
<directory suffix="Test.php">./tests/Pdf</directory>
</testsuite>
</testsuites>
<php> <php>
<env name="APP_ENV" value="testing"/> <env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/> <env name="BCRYPT_ROUNDS" value="4"/>
@ -63,7 +54,5 @@
<env name="QUEUE_CONNECTION" value="sync"/> <env name="QUEUE_CONNECTION" value="sync"/>
<env name="MAIL_MAILER" value="array"/> <env name="MAIL_MAILER" value="array"/>
</php> </php>
<logging> <logging/>
<log type="coverage-clover" target="coverage.xml"/>
</logging>
</phpunit> </phpunit>

View File

@ -134,15 +134,15 @@ class ClientTest extends TestCase
*/ */
public function testClientRestEndPoints() public function testClientRestEndPoints()
{ {
factory(\App\Models\Client::class, 3)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) { Client::factory()->count(3)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 2)->create([ ClientContact::factory()->count(2)->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -204,15 +204,15 @@ class ClientTest extends TestCase
public function testDefaultTimeZoneFromClientModel() public function testDefaultTimeZoneFromClientModel()
{ {
$account = factory(\App\Models\Account::class)->create(); $account = Account::factory()->create();
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
]); ]);
$account->default_company_id = $company->id; $account->default_company_id = $company->id;
$account->save(); $account->save();
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
'email' => 'whiz@gmail.com', 'email' => 'whiz@gmail.com',
@ -239,15 +239,15 @@ class ClientTest extends TestCase
'is_locked' => 0, 'is_locked' => 0,
]); ]);
factory(\App\Models\Client::class, 3)->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) { Client::factory()->count(3)->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) {
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $company->id, 'company_id' => $company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 2)->create([ ClientContact::factory()->count(2)->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $company->id, 'company_id' => $company->id,
@ -270,15 +270,15 @@ class ClientTest extends TestCase
public function testCreatingClientAndContacts() public function testCreatingClientAndContacts()
{ {
$account = factory(\App\Models\Account::class)->create(); $account = Account::factory()->create();
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
]); ]);
$account->default_company_id = $company->id; $account->default_company_id = $company->id;
$account->save(); $account->save();
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
'email' => 'whiz@gmail.com', 'email' => 'whiz@gmail.com',

View File

@ -12,6 +12,7 @@ namespace Tests\Feature;
use App\Models\Account; use App\Models\Account;
use App\Models\Client; use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Credit; use App\Models\Credit;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@ -41,15 +42,15 @@ class CreditTest extends TestCase
public function testCreditsList() public function testCreditsList()
{ {
factory(Client::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) { Client::factory()->count(3)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -58,7 +59,7 @@ class CreditTest extends TestCase
$client = Client::all()->first(); $client = Client::all()->first();
factory(Credit::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]); Credit::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$response = $this->withHeaders([ $response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'), 'X-API-SECRET' => config('ninja.api_secret'),

View File

@ -18,6 +18,8 @@ use App\Factory\InvoiceInvitationFactory;
use App\Jobs\Account\CreateAccount; use App\Jobs\Account\CreateAccount;
use App\Models\Account; use App\Models\Account;
use App\Models\Client; use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Company;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\InvoiceInvitation; use App\Models\InvoiceInvitation;
use App\Models\User; use App\Models\User;
@ -56,8 +58,8 @@ class InvitationTest extends TestCase
public function testInvoiceCreationAfterInvoiceMarkedSent() public function testInvoiceCreationAfterInvoiceMarkedSent()
{ {
$account = factory(\App\Models\Account::class)->create(); $account = Account::factory()->create();
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
]); ]);
@ -67,7 +69,7 @@ class InvitationTest extends TestCase
$user = User::where('email', 'user@example.com')->first(); $user = User::where('email', 'user@example.com')->first();
if (! $user) { if (! $user) {
$user = factory(\App\Models\User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
]); ]);
@ -94,15 +96,15 @@ class InvitationTest extends TestCase
'is_locked' => 0, 'is_locked' => 0,
]); ]);
factory(\App\Models\Client::class)->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) { Client::factory()->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) {
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $company->id, 'company_id' => $company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 2)->create([ ClientContact::factory()->count(2)->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $company->id, 'company_id' => $company->id,
@ -111,7 +113,7 @@ class InvitationTest extends TestCase
$client = Client::whereUserId($user->id)->whereCompanyId($company->id)->first(); $client = Client::whereUserId($user->id)->whereCompanyId($company->id)->first();
factory(\App\Models\Invoice::class, 5)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]); Invoice::factory()->count(5)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
$invoice = Invoice::whereUserId($user->id)->whereCompanyId($company->id)->whereClientId($client->id)->first(); $invoice = Invoice::whereUserId($user->id)->whereCompanyId($company->id)->whereClientId($client->id)->first();

View File

@ -15,6 +15,7 @@ use App\DataMapper\CompanySettings;
use App\Factory\InvoiceFactory; use App\Factory\InvoiceFactory;
use App\Models\Account; use App\Models\Account;
use App\Models\Client; use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Invoice; use App\Models\Invoice;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@ -51,15 +52,15 @@ class InvoiceTest extends TestCase
public function testInvoiceList() public function testInvoiceList()
{ {
factory(\App\Models\Client::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) { Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -68,7 +69,7 @@ class InvoiceTest extends TestCase
$client = Client::all()->first(); $client = Client::all()->first();
factory(\App\Models\Invoice::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]); Invoice::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$response = $this->withHeaders([ $response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'), 'X-API-SECRET' => config('ninja.api_secret'),
@ -153,7 +154,7 @@ class InvoiceTest extends TestCase
public function testUniqueNumberValidation() public function testUniqueNumberValidation()
{ {
/* stub a invoice in the DB that we will use to test against later */ /* stub a invoice in the DB that we will use to test against later */
$invoice = factory(\App\Models\Invoice::class)->create([ $invoice = Invoice::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,

View File

@ -13,6 +13,7 @@ namespace Tests\Feature;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
use App\Models\Account; use App\Models\Account;
use App\Models\Client; use App\Models\Client;
use App\Models\Company;
use App\Models\CompanyToken; use App\Models\CompanyToken;
use App\Models\User; use App\Models\User;
use App\Utils\Traits\UserSessionAttributes; use App\Utils\Traits\UserSessionAttributes;
@ -58,7 +59,7 @@ class LoginTest extends TestCase
// $user = factory(User::class)->create([ // $user = factory(User::class)->create([
// // 'account_id' => $account->id, // // 'account_id' => $account->id,
// ]); // ]);
// $company = factory(\App\Models\Company::class)->make([ // $company = Company::factory()->make([
// 'account_id' => $account->id, // 'account_id' => $account->id,
// ]); // ]);
@ -90,7 +91,7 @@ class LoginTest extends TestCase
// $user = factory(User::class)->create([ // $user = factory(User::class)->create([
// // 'account_id' => $account->id, // // 'account_id' => $account->id,
// ]); // ]);
// $company = factory(\App\Models\Company::class)->make([ // $company = Company::factory()->make([
// 'account_id' => $account->id, // 'account_id' => $account->id,
// ]); // ]);
@ -120,7 +121,7 @@ class LoginTest extends TestCase
// $user = factory(User::class)->create([ // $user = factory(User::class)->create([
// // 'account_id' => $account->id, // // 'account_id' => $account->id,
// ]); // ]);
// $company = factory(\App\Models\Company::class)->make([ // $company = Company::factory()->make([
// 'account_id' => $account->id, // 'account_id' => $account->id,
// ]); // ]);
@ -140,14 +141,14 @@ class LoginTest extends TestCase
public function testApiLogin() public function testApiLogin()
{ {
$account = factory(Account::class)->create(); $account = Account::factory()->create();
$user = factory(User::class)->create([ $user = User::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
'email' => 'test@example.com', 'email' => 'test@example.com',
'password' => \Hash::make('123456'), 'password' => \Hash::make('123456'),
]); ]);
$company = factory(\App\Models\Company::class)->create([ $company = Company::factory()->create([
'account_id' => $account->id, 'account_id' => $account->id,
]); ]);

View File

@ -20,6 +20,7 @@ use App\Helpers\Invoice\InvoiceSum;
use App\Models\Account; use App\Models\Account;
use App\Models\Activity; use App\Models\Activity;
use App\Models\Client; use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Credit; use App\Models\Credit;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
@ -67,15 +68,15 @@ class PaymentTest extends TestCase
public function testPaymentList() public function testPaymentList()
{ {
factory(\App\Models\Client::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) { Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -84,7 +85,7 @@ class PaymentTest extends TestCase
$client = Client::all()->first(); $client = Client::all()->first();
factory(\App\Models\Payment::class, 1)->create( Payment::factory()->create(
['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $client->id] ['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $client->id]
); );
@ -98,7 +99,7 @@ class PaymentTest extends TestCase
public function testPaymentRESTEndPoints() public function testPaymentRESTEndPoints()
{ {
factory(\App\Models\Payment::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]); Payment::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$Payment = Payment::all()->last(); $Payment = Payment::all()->last();
@ -271,7 +272,7 @@ class PaymentTest extends TestCase
$client = ClientFactory::create($this->company->id, $this->user->id); $client = ClientFactory::create($this->company->id, $this->user->id);
$client->save(); $client->save();
factory(\App\Models\ClientContact::class)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' =>$this->company->id, 'company_id' =>$this->company->id,
@ -347,7 +348,7 @@ class PaymentTest extends TestCase
$client->setRelation('company', $this->company); $client->setRelation('company', $this->company);
$client->save(); $client->save();
$client_contact = factory(\App\Models\ClientContact::class, 1)->create([ $client_contact = ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -423,7 +424,7 @@ class PaymentTest extends TestCase
$client = ClientFactory::create($this->company->id, $this->user->id); $client = ClientFactory::create($this->company->id, $this->user->id);
$client->save(); $client->save();
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -431,7 +432,7 @@ class PaymentTest extends TestCase
'send_email' => true, 'send_email' => true,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -495,7 +496,7 @@ class PaymentTest extends TestCase
$client = ClientFactory::create($this->company->id, $this->user->id); $client = ClientFactory::create($this->company->id, $this->user->id);
$client->save(); $client->save();
$contact = factory(\App\Models\ClientContact::class, 1)->create([ $contact = ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -503,7 +504,7 @@ class PaymentTest extends TestCase
'send_email' => true, 'send_email' => true,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,

View File

@ -14,6 +14,7 @@ use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
use App\Models\Account; use App\Models\Account;
use App\Models\Client; use App\Models\Client;
use App\Models\ClientContact;
use App\Models\RecurringInvoice; use App\Models\RecurringInvoice;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@ -55,15 +56,16 @@ class RecurringInvoiceTest extends TestCase
public function testRecurringInvoiceList() public function testRecurringInvoiceList()
{ {
factory(\App\Models\Client::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) { Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -72,7 +74,7 @@ class RecurringInvoiceTest extends TestCase
$client = Client::all()->first(); $client = Client::all()->first();
factory(\App\Models\RecurringInvoice::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]); RecurringInvoice::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$response = $this->withHeaders([ $response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'), 'X-API-SECRET' => config('ninja.api_secret'),
@ -84,15 +86,16 @@ class RecurringInvoiceTest extends TestCase
public function testRecurringInvoiceRESTEndPoints() public function testRecurringInvoiceRESTEndPoints()
{ {
factory(\App\Models\Client::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) { Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'is_primary' => 1, 'is_primary' => 1,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $c->id, 'client_id' => $c->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -100,7 +103,7 @@ class RecurringInvoiceTest extends TestCase
}); });
$client = Client::all()->first(); $client = Client::all()->first();
factory(\App\Models\RecurringInvoice::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]); RecurringInvoice::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$RecurringInvoice = RecurringInvoice::where('user_id', $this->user->id)->first(); $RecurringInvoice = RecurringInvoice::where('user_id', $this->user->id)->first();
$RecurringInvoice->save(); $RecurringInvoice->save();

View File

@ -55,7 +55,7 @@ class RecurringQuoteTest extends TestCase
public function testRecurringQuoteList() public function testRecurringQuoteList()
{ {
factory(\App\Models\RecurringQuote::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]); RecurringQuote::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$response = $this->withHeaders([ $response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'), 'X-API-SECRET' => config('ninja.api_secret'),
@ -67,7 +67,7 @@ class RecurringQuoteTest extends TestCase
public function testRecurringQuoteRESTEndPoints() public function testRecurringQuoteRESTEndPoints()
{ {
factory(\App\Models\RecurringQuote::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]); RecurringQuote::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$RecurringQuote = RecurringQuote::where('user_id', $this->user->id)->first(); $RecurringQuote = RecurringQuote::where('user_id', $this->user->id)->first();
$RecurringQuote->save(); $RecurringQuote->save();

View File

@ -12,6 +12,7 @@ namespace Tests\Feature\Shop;
use App\Factory\CompanyUserFactory; use App\Factory\CompanyUserFactory;
use App\Models\CompanyToken; use App\Models\CompanyToken;
use App\Models\Product;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Routing\Middleware\ThrottleRequests;
@ -98,7 +99,7 @@ class ShopInvoiceTest extends TestCase
$this->company->enable_shop_api = true; $this->company->enable_shop_api = true;
$this->company->save(); $this->company->save();
$product = factory(\App\Models\Product::class)->create([ $product = Product::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
]); ]);

View File

@ -138,7 +138,7 @@ class UserTest extends TestCase
$this->withoutMiddleware(PasswordProtection::class); $this->withoutMiddleware(PasswordProtection::class);
/* Create New Company */ /* Create New Company */
$company2 = factory(\App\Models\Company::class)->create([ $company2 = Company::factory()->create([
'account_id' => $this->account->id, 'account_id' => $this->account->id,
]); ]);

View File

@ -19,6 +19,8 @@ use App\Factory\InvoiceItemFactory;
use App\Jobs\Invoice\MarkInvoicePaid; use App\Jobs\Invoice\MarkInvoicePaid;
use App\Models\Account; use App\Models\Account;
use App\Models\Activity; use App\Models\Activity;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Company; use App\Models\Company;
use App\Models\CompanyLedger; use App\Models\CompanyLedger;
use App\Models\CompanyToken; use App\Models\CompanyToken;
@ -79,8 +81,8 @@ class CompanyLedgerTest extends TestCase
} }
} }
$this->account = factory(\App\Models\Account::class)->create(); $this->account = Account::factory()->create();
$this->company = factory(\App\Models\Company::class)->create([ $this->company = Company::factory()->create([
'account_id' => $this->account->id, 'account_id' => $this->account->id,
]); ]);
@ -108,7 +110,7 @@ class CompanyLedgerTest extends TestCase
$this->user = User::whereEmail('user@example.com')->first(); $this->user = User::whereEmail('user@example.com')->first();
if (! $this->user) { if (! $this->user) {
$this->user = factory(\App\Models\User::class)->create([ $this->user = User::factory()->create([
'account_id' => $this->account->id, 'account_id' => $this->account->id,
'password' => Hash::make('ALongAndBriliantPassword'), 'password' => Hash::make('ALongAndBriliantPassword'),
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
@ -130,12 +132,12 @@ class CompanyLedgerTest extends TestCase
$company_token->token = $this->token; $company_token->token = $this->token;
$company_token->save(); $company_token->save();
$this->client = factory(\App\Models\Client::class)->create([ $this->client = Client::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
]); ]);
factory(\App\Models\ClientContact::class, 1)->create([ ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,

View File

@ -40,18 +40,18 @@ class MultiDBUserTest extends TestCase
User::unguard(); User::unguard();
$ac = factory(\App\Models\Account::class)->make(); $ac = Account::factory()->make();
$ac->setHidden(['hashed_id']); $ac->setHidden(['hashed_id']);
$account = Account::on('db-ninja-01')->create($ac->toArray()); $account = Account::on('db-ninja-01')->create($ac->toArray());
$account2 = Account::on('db-ninja-02')->create($ac->toArray()); $account2 = Account::on('db-ninja-02')->create($ac->toArray());
$company = factory(\App\Models\Company::class)->make([ $company = Company::factory()->make([
'account_id' => $account->id, 'account_id' => $account->id,
]); ]);
$company2 = factory(\App\Models\Company::class)->make([ $company2 = Company::factory()->make([
'account_id' => $account2->id, 'account_id' => $account2->id,
]); ]);

View File

@ -42,12 +42,12 @@ class UniqueEmailTest extends TestCase
$this->rule = new NewUniqueUserRule(); $this->rule = new NewUniqueUserRule();
$ac = factory(\App\Models\Account::class)->make(); $ac = Account::factory()->make();
$ac->setHidden(['hashed_id']); $ac->setHidden(['hashed_id']);
$account = Account::on('db-ninja-01')->create($ac->toArray()); $account = Account::on('db-ninja-01')->create($ac->toArray());
$company = factory(\App\Models\Company::class)->make([ $company = Company::factory()->make([
'account_id' => $account->id, 'account_id' => $account->id,
]); ]);
@ -55,11 +55,11 @@ class UniqueEmailTest extends TestCase
Company::on('db-ninja-01')->create($company->toArray()); Company::on('db-ninja-01')->create($company->toArray());
$ac2 = factory(\App\Models\Account::class)->make(); $ac2 = Account::factory()->make();
$ac2->setHidden(['hashed_id']); $ac2->setHidden(['hashed_id']);
$account2 = Account::on('db-ninja-02')->create($ac2->toArray()); $account2 = Account::on('db-ninja-02')->create($ac2->toArray());
$company2 = factory(\App\Models\Company::class)->make([ $company2 = Company::factory()->make([
'account_id' => $account2->id, 'account_id' => $account2->id,
]); ]);

View File

@ -24,17 +24,23 @@ use App\Factory\InvoiceInvitationFactory;
use App\Factory\InvoiceItemFactory; use App\Factory\InvoiceItemFactory;
use App\Factory\InvoiceToRecurringInvoiceFactory; use App\Factory\InvoiceToRecurringInvoiceFactory;
use App\Helpers\Invoice\InvoiceSum; use App\Helpers\Invoice\InvoiceSum;
use App\Models\Account;
use App\Models\Client; use App\Models\Client;
use App\Models\ClientContact; use App\Models\ClientContact;
use App\Models\Company;
use App\Models\CompanyGateway; use App\Models\CompanyGateway;
use App\Models\CompanyToken; use App\Models\CompanyToken;
use App\Models\Credit; use App\Models\Credit;
use App\Models\Expense;
use App\Models\GroupSetting; use App\Models\GroupSetting;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\InvoiceInvitation; use App\Models\InvoiceInvitation;
use App\Models\Quote; use App\Models\Quote;
use App\Models\QuoteInvitation;
use App\Models\RecurringInvoice; use App\Models\RecurringInvoice;
use App\Models\User; use App\Models\User;
use App\Models\Vendor;
use App\Models\VendorContact;
use App\Utils\Traits\CompanyGatewayFeesAndLimitsSaver; use App\Utils\Traits\CompanyGatewayFeesAndLimitsSaver;
use App\Utils\Traits\GeneratesCounter; use App\Utils\Traits\GeneratesCounter;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
@ -96,8 +102,9 @@ trait MockAccountData
} }
} }
$this->account = factory(\App\Models\Account::class)->create();
$this->company = factory(\App\Models\Company::class)->create([ $this->account = Account::factory()->create();
$this->company = Company::factory()->create([
'account_id' => $this->account->id, 'account_id' => $this->account->id,
]); ]);
@ -125,7 +132,8 @@ trait MockAccountData
$this->user = User::whereEmail('user@example.com')->first(); $this->user = User::whereEmail('user@example.com')->first();
if (! $this->user) { if (! $this->user) {
$this->user = factory(\App\Models\User::class)->create([
$this->user = User::factory()->create([
'account_id' => $this->account->id, 'account_id' => $this->account->id,
'confirmation_code' => $this->createDbHash(config('database.default')), 'confirmation_code' => $this->createDbHash(config('database.default')),
]); ]);
@ -150,12 +158,12 @@ trait MockAccountData
$company_token->save(); $company_token->save();
$this->client = factory(\App\Models\Client::class)->create([ $this->client = Client::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
]); ]);
$contact = factory(\App\Models\ClientContact::class)->create([ $contact = ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -163,19 +171,21 @@ trait MockAccountData
'send_email' => true, 'send_email' => true,
]); ]);
$contact2 = factory(\App\Models\ClientContact::class)->create([
$contact2 = ClientContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'send_email' => true, 'send_email' => true,
]); ]);
$this->vendor = factory(\App\Models\Vendor::class)->create([ $this->vendor = Vendor::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
]); ]);
$vendor_contact = factory(\App\Models\VendorContact::class)->create([
$vendor_contact = VendorContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'vendor_id' => $this->vendor->id, 'vendor_id' => $this->vendor->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -183,22 +193,20 @@ trait MockAccountData
'send_email' => true, 'send_email' => true,
]); ]);
$vendor_contact2 = factory(\App\Models\VendorContact::class)->create([ $vendor_contact2 = VendorContact::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'vendor_id' => $this->vendor->id, 'vendor_id' => $this->vendor->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'send_email' => true, 'send_email' => true,
]); ]);
$this->expense = factory(\App\Models\Expense::class)->create([
$this->expense = Expense::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
]); ]);
// $rels = collect($contact, $contact2);
// $this->client->setRelation('contacts', $rels);
// $this->client->save();
$gs = new GroupSetting; $gs = new GroupSetting;
$gs->name = 'Test'; $gs->name = 'Test';
$gs->company_id = $this->client->company_id; $gs->company_id = $this->client->company_id;
@ -215,7 +223,7 @@ trait MockAccountData
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id $this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
$this->invoice->client_id = $this->client->id; $this->invoice->client_id = $this->client->id;
// $this->invoice = factory(\App\Models\Invoice::class)->create([ // $this->invoice = Invoice::factory()->create([
// 'user_id' => $this->user->id, // 'user_id' => $this->user->id,
// 'client_id' => $this->client->id, // 'client_id' => $this->client->id,
// 'company_id' => $this->company->id, // 'company_id' => $this->company->id,
@ -238,15 +246,14 @@ trait MockAccountData
//$this->invoice->service()->createInvitations()->markSent(); //$this->invoice->service()->createInvitations()->markSent();
//$this->invoice->service()->createInvitations(); //$this->invoice->service()->createInvitations();
InvoiceInvitation::factory()->create([
factory(\App\Models\InvoiceInvitation::class)->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'client_contact_id' => $contact->id, 'client_contact_id' => $contact->id,
'invoice_id' => $this->invoice->id, 'invoice_id' => $this->invoice->id,
]); ]);
factory(\App\Models\InvoiceInvitation::class)->create([ InvoiceInvitation::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'client_contact_id' => $contact2->id, 'client_contact_id' => $contact2->id,
@ -255,7 +262,7 @@ trait MockAccountData
$this->invoice->service()->markSent(); $this->invoice->service()->markSent();
$this->quote = factory(\App\Models\Quote::class)->create([ $this->quote = Quote::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -276,14 +283,14 @@ trait MockAccountData
//$this->quote->service()->createInvitations()->markSent(); //$this->quote->service()->createInvitations()->markSent();
factory(\App\Models\QuoteInvitation::class)->create([ QuoteInvitation::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'client_contact_id' => $contact->id, 'client_contact_id' => $contact->id,
'quote_id' => $this->quote->id, 'quote_id' => $this->quote->id,
]); ]);
factory(\App\Models\QuoteInvitation::class)->create([ QuoteInvitation::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'client_contact_id' => $contact2->id, 'client_contact_id' => $contact2->id,