mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/** @extends Factory<User> */
|
|
class UserFactory extends Factory
|
|
{
|
|
/**
|
|
* The name of the factory's corresponding model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $model = User::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function definition()
|
|
{
|
|
static $password;
|
|
|
|
return [
|
|
'auth_type' => 'mysql',
|
|
'username' => $this->faker->unique()->userName, /* @phpstan-ignore-line */
|
|
'realname' => $this->faker->name,
|
|
'email' => $this->faker->safeEmail,
|
|
'password' => $password ?: $password = bcrypt('secret'),
|
|
'level' => 1,
|
|
];
|
|
}
|
|
|
|
public function admin()
|
|
{
|
|
return $this->state(function () {
|
|
return [
|
|
'level' => '10',
|
|
];
|
|
});
|
|
}
|
|
|
|
public function read()
|
|
{
|
|
return $this->state(function () {
|
|
return [
|
|
'level' => '5',
|
|
];
|
|
});
|
|
}
|
|
}
|