2014-05-14 13:24:20 +00:00
|
|
|
<?php namespace Backend\Database\Seeds;
|
|
|
|
|
|
|
|
|
|
use Seeder;
|
|
|
|
|
use Backend\Models\User;
|
2017-07-13 09:29:50 +00:00
|
|
|
use Backend\Models\UserRole;
|
2014-05-14 13:24:20 +00:00
|
|
|
use Backend\Models\UserGroup;
|
|
|
|
|
|
|
|
|
|
class SeedSetupAdmin extends Seeder
|
|
|
|
|
{
|
2014-11-01 05:14:38 +00:00
|
|
|
public static $email = 'admin@domain.tld';
|
2014-05-14 13:24:20 +00:00
|
|
|
public static $login = 'admin';
|
2020-02-27 08:59:12 +00:00
|
|
|
public static $password = 'admin';
|
2014-05-14 13:24:20 +00:00
|
|
|
public static $firstName = 'Admin';
|
|
|
|
|
public static $lastName = 'Person';
|
|
|
|
|
|
|
|
|
|
public function setDefaults($values)
|
|
|
|
|
{
|
2014-10-10 21:34:34 +00:00
|
|
|
if (!is_array($values)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-05-14 13:24:20 +00:00
|
|
|
foreach ($values as $attribute => $value) {
|
|
|
|
|
static::$$attribute = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function run()
|
|
|
|
|
{
|
2017-07-13 09:29:50 +00:00
|
|
|
UserRole::create([
|
|
|
|
|
'name' => 'Publisher',
|
|
|
|
|
'code' => UserRole::CODE_PUBLISHER,
|
|
|
|
|
'description' => 'Site editor with access to publishing tools.',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$role = UserRole::create([
|
|
|
|
|
'name' => 'Developer',
|
|
|
|
|
'code' => UserRole::CODE_DEVELOPER,
|
|
|
|
|
'description' => 'Site administrator with access to developer tools.',
|
|
|
|
|
]);
|
|
|
|
|
|
2014-05-14 13:24:20 +00:00
|
|
|
$group = UserGroup::create([
|
2015-07-03 23:34:35 +00:00
|
|
|
'name' => 'Owners',
|
2017-07-13 09:29:50 +00:00
|
|
|
'code' => UserGroup::CODE_OWNERS,
|
2015-07-03 23:34:35 +00:00
|
|
|
'description' => 'Default group for website owners.',
|
|
|
|
|
'is_new_user_default' => false
|
2014-05-14 13:24:20 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$user = User::create([
|
|
|
|
|
'email' => static::$email,
|
|
|
|
|
'login' => static::$login,
|
|
|
|
|
'password' => static::$password,
|
|
|
|
|
'password_confirmation' => static::$password,
|
|
|
|
|
'first_name' => static::$firstName,
|
|
|
|
|
'last_name' => static::$lastName,
|
2015-11-27 23:21:41 +00:00
|
|
|
'permissions' => [],
|
2016-01-04 06:54:23 +00:00
|
|
|
'is_superuser' => true,
|
2017-07-13 09:29:50 +00:00
|
|
|
'is_activated' => true,
|
|
|
|
|
'role_id' => $role->id
|
2014-05-14 13:24:20 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$user->addGroup($group);
|
|
|
|
|
}
|
2014-10-10 21:34:34 +00:00
|
|
|
}
|