2020-11-14 16:57:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
2021-06-04 15:19:33 +00:00
|
|
|
use Illuminate\Support\Str;
|
2020-11-14 16:57:25 +00:00
|
|
|
|
|
|
|
class UserFactory extends Factory
|
|
|
|
{
|
|
|
|
protected $model = User::class;
|
|
|
|
|
2020-12-22 20:11:22 +00:00
|
|
|
/** @return array<mixed> */
|
2020-11-14 16:57:25 +00:00
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'name' => $this->faker->name,
|
|
|
|
'email' => $this->faker->email,
|
|
|
|
'password' => Hash::make('secret'),
|
|
|
|
'is_admin' => false,
|
2021-06-04 15:19:33 +00:00
|
|
|
'preferences' => [
|
|
|
|
'lastfm_session_key' => Str::random(),
|
|
|
|
],
|
|
|
|
'remember_token' => Str::random(10),
|
2020-11-14 16:57:25 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-12-22 20:11:22 +00:00
|
|
|
public function admin(): self
|
2020-11-14 16:57:25 +00:00
|
|
|
{
|
2021-06-05 10:47:56 +00:00
|
|
|
return $this->state(fn () => ['is_admin' => true]); // @phpcs:ignore
|
2020-11-14 16:57:25 +00:00
|
|
|
}
|
|
|
|
}
|