mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
User seeders
This commit is contained in:
parent
f865c621ef
commit
7e728094a1
|
@ -2,12 +2,14 @@
|
|||
|
||||
use App\Models\Company;
|
||||
|
||||
|
||||
|
||||
$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'first_name' => $faker->firstName,
|
||||
'last_name' => $faker->lastName,
|
||||
'username' => $faker->username,
|
||||
'password' => $faker->password,
|
||||
'password' => bcrypt('password'),
|
||||
'permissions' => '{"user":"0"}',
|
||||
'email' => $faker->safeEmail,
|
||||
'company_id' => function () {
|
||||
|
@ -15,14 +17,36 @@ $factory->define(App\Models\User::class, function (Faker\Generator $faker) {
|
|||
},
|
||||
'locale' => $faker->locale,
|
||||
'employee_num' => $faker->numberBetween(3500, 35050),
|
||||
'jobtitle' => $faker->word,
|
||||
'jobtitle' => $faker->jobTitle,
|
||||
'department_id' => rand(1,6),
|
||||
'phone' => $faker->phoneNumber,
|
||||
'notes' => $faker->sentence,
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'notes' => 'Created by DB seeder',
|
||||
'location_id' => rand(1,5),
|
||||
'activated' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->state(App\Models\User::class, 'first-admin', function ($faker) {
|
||||
return [
|
||||
'first_name' => 'Admin',
|
||||
'last_name' => 'User',
|
||||
'username' => 'admin',
|
||||
'permissions' => '{"superuser":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\User::class, 'snipe-admin', function ($faker) {
|
||||
return [
|
||||
'first_name' => 'Snipe E.',
|
||||
'last_name' => 'Head',
|
||||
'username' => 'snipe',
|
||||
'email' => 'snipe@snipe.net',
|
||||
'permissions' => '{"superuser":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
// USER GLOBAL PERMISSION STATES
|
||||
$factory->state(App\Models\User::class, 'superuser', function ($faker) {
|
||||
return [
|
||||
|
@ -33,6 +57,7 @@ $factory->state(App\Models\User::class, 'superuser', function ($faker) {
|
|||
$factory->state(App\Models\User::class, 'admin', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"admin":"1"}',
|
||||
'manager_id' => rand(1,2),
|
||||
];
|
||||
});
|
||||
// USER ASSET PERMISSION STATES
|
||||
|
|
|
@ -12,7 +12,45 @@ class UserSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
// Don't truncate the user column, that might suck.
|
||||
factory(User::class, 10)->create();
|
||||
User::truncate();
|
||||
factory(User::class, 1)->states('first-admin')->create();
|
||||
factory(User::class, 1)->states('snipe-admin')->create();
|
||||
factory(User::class, 3)->states('superuser')->create();
|
||||
factory(User::class, 3)->states('admin')->create();
|
||||
factory(User::class, 1)->states('view-assets')->create();
|
||||
factory(User::class, 1)->states('create-assets')->create();
|
||||
factory(User::class, 1)->states('edit-assets')->create();
|
||||
factory(User::class, 1)->states('delete-assets')->create();
|
||||
factory(User::class, 1)->states('checkin-assets')->create();
|
||||
factory(User::class, 1)->states('checkout-assets')->create();
|
||||
factory(User::class, 1)->states('view-requestable-assets')->create();
|
||||
factory(User::class, 1)->states('view-accessories')->create();
|
||||
factory(User::class, 1)->states('create-accessories')->create();
|
||||
factory(User::class, 1)->states('view-accessories')->create();
|
||||
factory(User::class, 1)->states('delete-accessories')->create();
|
||||
factory(User::class, 1)->states('edit-accessories')->create();
|
||||
factory(User::class, 1)->states('checkout-accessories')->create();
|
||||
factory(User::class, 1)->states('checkin-accessories')->create();
|
||||
factory(User::class, 1)->states('view-consumables')->create();
|
||||
factory(User::class, 1)->states('create-consumables')->create();
|
||||
factory(User::class, 1)->states('edit-consumables')->create();
|
||||
factory(User::class, 1)->states('delete-consumables')->create();
|
||||
factory(User::class, 1)->states('checkout-consumables')->create();
|
||||
factory(User::class, 1)->states('view-licenses')->create();
|
||||
factory(User::class, 1)->states('edit-licenses')->create();
|
||||
factory(User::class, 1)->states('delete-licenses')->create();
|
||||
factory(User::class, 1)->states('create-licenses')->create();
|
||||
factory(User::class, 1)->states('checkout-licenses')->create();
|
||||
factory(User::class, 1)->states('view-keys-licenses')->create();
|
||||
factory(User::class, 1)->states('view-components')->create();
|
||||
factory(User::class, 1)->states('edit-components')->create();
|
||||
factory(User::class, 1)->states('create-components')->create();
|
||||
factory(User::class, 1)->states('delete-components')->create();
|
||||
factory(User::class, 1)->states('checkout-components')->create();
|
||||
factory(User::class, 1)->states('checkin-components')->create();
|
||||
factory(User::class, 1)->states('view-users')->create();
|
||||
factory(User::class, 1)->states('edit-users')->create();
|
||||
factory(User::class, 1)->states('delete-users')->create();
|
||||
factory(User::class, 1)->states('create-users')->create();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue