2015-03-16 22:45:25 +01:00
|
|
|
<?php
|
|
|
|
|
2015-08-20 17:09:04 +02:00
|
|
|
use App\Models\Account;
|
2017-03-31 17:02:56 +02:00
|
|
|
use App\Models\AccountEmailSettings;
|
2015-09-25 11:57:40 +02:00
|
|
|
use App\Models\Affiliate;
|
2016-06-06 21:45:21 +02:00
|
|
|
use App\Models\Client;
|
2017-01-30 20:40:43 +01:00
|
|
|
use App\Models\Company;
|
2016-06-06 21:45:21 +02:00
|
|
|
use App\Models\Contact;
|
2017-01-30 20:40:43 +01:00
|
|
|
use App\Models\Country;
|
2016-08-15 22:14:08 +02:00
|
|
|
use App\Models\DateFormat;
|
2017-01-30 20:40:43 +01:00
|
|
|
use App\Models\Font;
|
|
|
|
use App\Models\InvoiceDesign;
|
|
|
|
use App\Models\Product;
|
|
|
|
use App\Models\User;
|
2015-08-20 17:09:04 +02:00
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
class UserTableSeeder extends Seeder
|
|
|
|
{
|
2017-01-30 17:05:31 +01:00
|
|
|
public function run()
|
|
|
|
{
|
2015-08-20 17:09:04 +02:00
|
|
|
$this->command->info('Running UserTableSeeder');
|
|
|
|
|
|
|
|
Eloquent::unguard();
|
|
|
|
|
2016-05-05 19:18:02 +02:00
|
|
|
$faker = Faker\Factory::create();
|
2016-04-19 04:35:18 +02:00
|
|
|
$company = Company::create();
|
2016-05-22 15:55:25 +02:00
|
|
|
|
2015-08-20 17:09:04 +02:00
|
|
|
$account = Account::create([
|
2016-05-05 19:18:02 +02:00
|
|
|
'name' => $faker->name,
|
|
|
|
'address1' => $faker->streetAddress,
|
|
|
|
'address2' => $faker->secondaryAddress,
|
|
|
|
'city' => $faker->city,
|
|
|
|
'state' => $faker->state,
|
|
|
|
'postal_code' => $faker->postcode,
|
2017-12-01 08:28:01 +01:00
|
|
|
'currency_id' => DEFAULT_CURRENCY,
|
2016-05-22 15:55:25 +02:00
|
|
|
'country_id' => Country::all()->random()->id,
|
2017-04-02 19:46:01 +02:00
|
|
|
'account_key' => strtolower(str_random(RANDOM_KEY_LENGTH)),
|
2016-05-05 19:18:02 +02:00
|
|
|
'invoice_terms' => $faker->text($faker->numberBetween(50, 300)),
|
|
|
|
'work_phone' => $faker->phoneNumber,
|
|
|
|
'work_email' => $faker->safeEmail,
|
2017-06-21 16:42:17 +02:00
|
|
|
//'invoice_design_id' => InvoiceDesign::where('id', '<', CUSTOM_DESIGN1)->get()->random()->id,
|
|
|
|
//'header_font_id' => min(Font::all()->random()->id, 17),
|
|
|
|
//'body_font_id' => min(Font::all()->random()->id, 17),
|
2016-05-05 19:18:02 +02:00
|
|
|
'primary_color' => $faker->hexcolor,
|
2017-02-07 10:49:06 +01:00
|
|
|
'timezone_id' => 58,
|
2016-04-19 23:02:02 +02:00
|
|
|
'company_id' => $company->id,
|
2017-02-08 17:00:09 +01:00
|
|
|
'pdf_email_attachment' => true,
|
2015-08-20 17:09:04 +02:00
|
|
|
]);
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2017-03-31 17:02:56 +02:00
|
|
|
$emailSettings = AccountEmailSettings::create([
|
|
|
|
'account_id' => $account->id
|
|
|
|
]);
|
|
|
|
|
2016-06-06 21:45:21 +02:00
|
|
|
$user = User::create([
|
|
|
|
'first_name' => $faker->firstName,
|
|
|
|
'last_name' => $faker->lastName,
|
2015-08-20 17:09:04 +02:00
|
|
|
'email' => TEST_USERNAME,
|
|
|
|
'username' => TEST_USERNAME,
|
|
|
|
'account_id' => $account->id,
|
|
|
|
'password' => Hash::make(TEST_PASSWORD),
|
2015-08-30 14:08:15 +02:00
|
|
|
'registered' => true,
|
|
|
|
'confirmed' => true,
|
2016-05-05 19:18:02 +02:00
|
|
|
'notify_sent' => false,
|
|
|
|
'notify_paid' => false,
|
2016-06-07 13:41:07 +02:00
|
|
|
'is_admin' => 1,
|
2015-08-20 17:09:04 +02:00
|
|
|
]);
|
2015-09-25 11:57:40 +02:00
|
|
|
|
2016-06-06 21:45:21 +02:00
|
|
|
$client = Client::create([
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'account_id' => $account->id,
|
|
|
|
'public_id' => 1,
|
|
|
|
'name' => $faker->name,
|
|
|
|
'address1' => $faker->streetAddress,
|
|
|
|
'address2' => $faker->secondaryAddress,
|
|
|
|
'city' => $faker->city,
|
|
|
|
'state' => $faker->state,
|
|
|
|
'postal_code' => $faker->postcode,
|
2016-06-20 16:14:43 +02:00
|
|
|
'country_id' => DEFAULT_COUNTRY,
|
|
|
|
'currency_id' => DEFAULT_CURRENCY,
|
2016-06-06 21:45:21 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
Contact::create([
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'account_id' => $account->id,
|
|
|
|
'client_id' => $client->id,
|
|
|
|
'public_id' => 1,
|
2016-07-04 18:49:01 +02:00
|
|
|
'email' => env('TEST_EMAIL', TEST_USERNAME),
|
2016-06-20 16:14:43 +02:00
|
|
|
'is_primary' => true,
|
2017-01-30 17:05:31 +01:00
|
|
|
'send_invoice' => true,
|
2017-04-30 20:44:52 +02:00
|
|
|
'contact_key' => strtolower(str_random(RANDOM_KEY_LENGTH)),
|
2016-06-06 21:45:21 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
Product::create([
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'account_id' => $account->id,
|
|
|
|
'public_id' => 1,
|
|
|
|
'product_key' => 'ITEM',
|
|
|
|
'notes' => 'Something nice...',
|
|
|
|
'cost' => 10,
|
|
|
|
]);
|
|
|
|
|
2015-09-25 11:57:40 +02:00
|
|
|
Affiliate::create([
|
2017-01-30 20:40:43 +01:00
|
|
|
'affiliate_key' => SELF_HOST_AFFILIATE_KEY,
|
2015-09-25 11:57:40 +02:00
|
|
|
]);
|
2017-01-30 17:05:31 +01:00
|
|
|
}
|
2016-05-22 15:55:25 +02:00
|
|
|
}
|