68 lines
1.5 KiB
PHP
Raw Normal View History

2019-11-22 17:35:46 +03:00
<?php
2020-10-14 17:07:59 +03:00
namespace Database\Factories;
use App\Abstracts\Factory;
use App\Models\Auth\User as Model;
2019-11-22 17:35:46 +03:00
use Illuminate\Support\Str;
2020-10-14 17:07:59 +03:00
class User extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Model::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi'; // password
2019-11-22 17:35:46 +03:00
2020-10-14 17:07:59 +03:00
return [
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
'password' => $password,
'password_confirmation' => $password,
'remember_token' => Str::random(10),
'locale' => 'en-GB',
'companies' => ['1'],
'roles' => ['1'],
'enabled' => $this->faker->boolean ? 1 : 0,
];
}
2020-01-07 01:28:05 +03:00
2020-10-14 17:07:59 +03:00
/**
* Indicate that the model is enabled.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function enabled()
{
return $this->state(function (array $attributes) {
return [
'enabled' => 1,
];
});
}
2020-01-07 01:28:05 +03:00
2020-10-14 17:07:59 +03:00
/**
* Indicate that the model is disabled.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function disabled()
{
return $this->state(function (array $attributes) {
return [
'enabled' => 0,
];
});
}
}