Updates for RandomDataSeeder

This commit is contained in:
David Bomba 2023-03-10 16:37:17 +11:00
parent 19104ec0d5
commit 8e34d0ed0d
2 changed files with 152 additions and 91 deletions

76
composer.lock generated
View File

@ -380,16 +380,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.261.6",
"version": "3.261.8",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "63b03ec821473861af58439f1a35173e904d0f8c"
"reference": "9c38c82b7d3fb2b15957e71cae3957450e131ed8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/63b03ec821473861af58439f1a35173e904d0f8c",
"reference": "63b03ec821473861af58439f1a35173e904d0f8c",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/9c38c82b7d3fb2b15957e71cae3957450e131ed8",
"reference": "9c38c82b7d3fb2b15957e71cae3957450e131ed8",
"shasum": ""
},
"require": {
@ -468,9 +468,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.261.6"
"source": "https://github.com/aws/aws-sdk-php/tree/3.261.8"
},
"time": "2023-03-07T19:21:12+00:00"
"time": "2023-03-09T19:23:27+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -2171,16 +2171,16 @@
},
{
"name": "google/apiclient-services",
"version": "v0.289.1",
"version": "v0.289.0",
"source": {
"type": "git",
"url": "https://github.com/googleapis/google-api-php-client-services.git",
"reference": "df7e6cbab08f60509b3f360d8286c194ad2930e2"
"reference": "937f83a927db2d09db7eebb69ce2ac4114559bd7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/df7e6cbab08f60509b3f360d8286c194ad2930e2",
"reference": "df7e6cbab08f60509b3f360d8286c194ad2930e2",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/937f83a927db2d09db7eebb69ce2ac4114559bd7",
"reference": "937f83a927db2d09db7eebb69ce2ac4114559bd7",
"shasum": ""
},
"require": {
@ -2209,9 +2209,9 @@
],
"support": {
"issues": "https://github.com/googleapis/google-api-php-client-services/issues",
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.289.1"
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.289.0"
},
"time": "2023-03-01T17:20:18+00:00"
"time": "2023-02-26T01:10:11+00:00"
},
{
"name": "google/auth",
@ -2605,16 +2605,16 @@
},
{
"name": "guzzlehttp/psr7",
"version": "2.4.3",
"version": "2.4.4",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "67c26b443f348a51926030c83481b85718457d3d"
"reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d",
"reference": "67c26b443f348a51926030c83481b85718457d3d",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf",
"reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf",
"shasum": ""
},
"require": {
@ -2704,7 +2704,7 @@
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/2.4.3"
"source": "https://github.com/guzzle/psr7/tree/2.4.4"
},
"funding": [
{
@ -2720,7 +2720,7 @@
"type": "tidelift"
}
],
"time": "2022-10-26T14:07:24+00:00"
"time": "2023-03-09T13:19:02+00:00"
},
{
"name": "guzzlehttp/uri-template",
@ -14427,16 +14427,16 @@
},
{
"name": "myclabs/deep-copy",
"version": "1.11.0",
"version": "1.11.1",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614"
"reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
"reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
"shasum": ""
},
"require": {
@ -14474,7 +14474,7 @@
],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.11.0"
"source": "https://github.com/myclabs/DeepCopy/tree/1.11.1"
},
"funding": [
{
@ -14482,7 +14482,7 @@
"type": "tidelift"
}
],
"time": "2022-03-03T13:19:32+00:00"
"time": "2023-03-08T13:26:56+00:00"
},
{
"name": "netresearch/jsonmapper",
@ -15020,16 +15020,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.10.5",
"version": "1.10.6",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "1fb6f494d82455151ecf15c5c191923f5d84324e"
"reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/1fb6f494d82455151ecf15c5c191923f5d84324e",
"reference": "1fb6f494d82455151ecf15c5c191923f5d84324e",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/50d089a3e0904b0fe7e2cf2d4fd37d427d64235a",
"reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a",
"shasum": ""
},
"require": {
@ -15059,7 +15059,7 @@
],
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.10.5"
"source": "https://github.com/phpstan/phpstan/tree/1.10.6"
},
"funding": [
{
@ -15075,7 +15075,7 @@
"type": "tidelift"
}
],
"time": "2023-03-07T16:48:45+00:00"
"time": "2023-03-09T16:55:12+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -15397,16 +15397,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.6.4",
"version": "9.6.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d"
"reference": "86e761949019ae83f49240b2f2123fb5ab3b2fc5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9125ee085b6d95e78277dc07aa1f46f9e0607b8d",
"reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/86e761949019ae83f49240b2f2123fb5ab3b2fc5",
"reference": "86e761949019ae83f49240b2f2123fb5ab3b2fc5",
"shasum": ""
},
"require": {
@ -15439,8 +15439,8 @@
"sebastian/version": "^3.0.2"
},
"suggest": {
"ext-soap": "*",
"ext-xdebug": "*"
"ext-soap": "To be able to generate mocks based on WSDL files",
"ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage"
},
"bin": [
"phpunit"
@ -15479,7 +15479,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.4"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.5"
},
"funding": [
{
@ -15495,7 +15495,7 @@
"type": "tidelift"
}
],
"time": "2023-02-27T13:06:37+00:00"
"time": "2023-03-09T06:34:10+00:00"
},
{
"name": "sebastian/cli-parser",

View File

@ -11,37 +11,41 @@
namespace Database\Seeders;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use App\Events\Payment\PaymentWasCreated;
use App\Helpers\Invoice\InvoiceSum;
use App\Helpers\Invoice\InvoiceSumInclusive;
use App\Models\Account;
use App\Models\User;
use App\Utils\Ninja;
use App\Models\Quote;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Company;
use App\Models\CompanyGateway;
use App\Models\CompanyToken;
use App\Models\Credit;
use App\Models\GroupSetting;
use App\Models\Vendor;
use App\Models\Account;
use App\Models\Company;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Product;
use App\Models\PaymentHash;
use App\Models\PaymentType;
use App\Models\Product;
use App\Models\Quote;
use App\Models\RecurringInvoice;
use App\Models\User;
use App\Repositories\CreditRepository;
use App\Repositories\InvoiceRepository;
use App\Repositories\QuoteRepository;
use App\Utils\Ninja;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use App\Models\CompanyToken;
use App\Models\GroupSetting;
use App\Models\ClientContact;
use App\Models\VendorContact;
use App\Models\CompanyGateway;
use Illuminate\Database\Seeder;
use App\Models\RecurringInvoice;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use App\Helpers\Invoice\InvoiceSum;
use Illuminate\Support\Facades\Hash;
use App\Repositories\QuoteRepository;
use Illuminate\Support\Facades\Cache;
use App\Repositories\CreditRepository;
use Illuminate\Support\Facades\Schema;
use App\Repositories\InvoiceRepository;
use Illuminate\Database\Eloquent\Model;
use App\Events\Payment\PaymentWasCreated;
use App\Helpers\Invoice\InvoiceSumInclusive;
use App\Models\BankIntegration;
use App\Models\BankTransaction;
class RandomDataSeeder extends Seeder
{
@ -117,6 +121,58 @@ class RandomDataSeeder extends Seeder
'settings' => null,
]);
$permission_users = [
'permissions',
'products',
'invoices',
'quotes',
'clients',
'vendors',
'tasks',
'expenses',
'projects',
'credits',
'payments',
'bank_transactions',
'purchase_orders',
];
foreach ($permission_users as $p_user) {
nlog($p_user);
$user = User::firstOrNew([
'email' => "{$p_user}@example.com",
]);
$user->first_name = ucfirst($p_user);
$user->last_name = 'Example';
$user->password = Hash::make('password');
$user->account_id = $account->id;
$user->email_verified_at = now();
$user->save();
$company_token = CompanyToken::create([
'user_id' => $user->id,
'company_id' => $company->id,
'account_id' => $account->id,
'name' => 'test token',
'token' => \Illuminate\Support\Str::random(64),
]);
$user->companies()->attach($company->id, [
'account_id' => $account->id,
'is_owner' => 0,
'is_admin' => 0,
'is_locked' => 0,
'notifications' => CompanySettings::notificationDefaults(),
'permissions' => '',
'settings' => null,
]);
$user = null;
}
$user = User::firstOrNew([
'email' => 'user@example.com',
]);
@ -147,35 +203,6 @@ class RandomDataSeeder extends Seeder
]);
$user = User::firstOrNew([
'email' => 'permissions@example.com',
]);
$user->first_name = 'Permissions';
$user->last_name = 'Example';
$user->password = Hash::make('password');
$user->account_id = $account->id;
$user->email_verified_at = now();
$user->save();
$company_token = CompanyToken::create([
'user_id' => $user->id,
'company_id' => $company->id,
'account_id' => $account->id,
'name' => 'test token',
'token' => \Illuminate\Support\Str::random(64),
]);
$user->companies()->attach($company->id, [
'account_id' => $account->id,
'is_owner' => 0,
'is_admin' => 0,
'is_locked' => 0,
'notifications' => CompanySettings::notificationDefaults(),
'permissions' => '',
'settings' => null,
]);
$client = Client::factory()->create([
'user_id' => $user->id,
@ -195,6 +222,28 @@ class RandomDataSeeder extends Seeder
'password' => Hash::make('password'),
]);
$vendor = Vendor::factory()->create([
'user_id' => $user->id,
'company_id' => $company->id,
'name' => 'cypress'
]);
$vendor->number = $vendor->getNextVendorNumber($vendor);
$vendor->save();
VendorContact::factory()->create([
'user_id' => $user->id,
'vendor_id' => $vendor->id,
'company_id' => $company->id,
'is_primary' => 1,
'email' => 'cypress_vendor@example.com',
'password' => Hash::make('password'),
]);
/* Product Factory */
Product::factory()->count(2)->create(['user_id' => $user->id, 'company_id' => $company->id]);
@ -304,6 +353,18 @@ class RandomDataSeeder extends Seeder
'name' => 'Default Client Settings',
]);
$bi = BankIntegration::factory()->create([
'account_id' => $account->id,
'user_id' => $user->id,
'company_id' => $company->id,
]);
BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
'user_id' => $user->id,
'company_id' => $company->id,
]);
if (config('ninja.testvars.stripe')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;