koel/database/factories/UserFactory.php

33 lines
749 B
PHP
Raw Normal View History

<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
class UserFactory extends Factory
{
protected $model = User::class;
2020-12-22 20:11:22 +00:00
/** @return array<mixed> */
public function definition(): array
{
return [
'name' => $this->faker->name,
'email' => $this->faker->email,
'password' => Hash::make('secret'),
'is_admin' => false,
'preferences' => [],
'remember_token' => str_random(10),
];
}
2020-12-22 20:11:22 +00:00
public function admin(): self
{
2020-12-22 23:01:49 +00:00
return $this->state(function (): array { // phpcs:ignore
return ['is_admin' => true];
});
}
}