1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/database/seeds/UserTableSeeder.php

61 lines
1.8 KiB
PHP
Raw Normal View History

2015-03-16 22:45:25 +01:00
<?php
2015-08-20 17:09:04 +02:00
use App\Models\User;
2016-05-05 21:27:02 +02:00
use App\Models\Font;
2015-08-20 17:09:04 +02:00
use App\Models\Account;
2016-04-19 22:28:25 +02:00
use App\Models\Company;
2015-09-25 11:57:40 +02:00
use App\Models\Affiliate;
2016-05-05 19:18:02 +02:00
use App\Models\Country;
2016-05-05 21:12:33 +02:00
use App\Models\InvoiceDesign;
2016-05-05 19:18:02 +02:00
use Faker\Factory;
2015-08-20 17:09:04 +02:00
2015-03-16 22:45:25 +01:00
class UserTableSeeder extends Seeder
{
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();
$company = Company::create();
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,
'country_id' => Country::all()->random()->id,
2015-11-03 20:03:24 +01:00
'account_key' => 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,
2016-05-05 21:12:33 +02:00
'invoice_design_id' => min(InvoiceDesign::all()->random()->id, 10),
2016-05-05 21:32:26 +02:00
'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,
2015-08-20 17:09:04 +02:00
'timezone_id' => 1,
2016-04-19 23:02:02 +02:00
'company_id' => $company->id,
2015-08-20 17:09:04 +02:00
]);
2015-03-16 22:45:25 +01:00
2015-08-20 17:09:04 +02:00
User::create([
'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,
2015-08-20 17:09:04 +02:00
]);
2015-09-25 11:57:40 +02:00
Affiliate::create([
'affiliate_key' => SELF_HOST_AFFILIATE_KEY
]);
2015-03-16 22:45:25 +01:00
}
}