laravel 8
This commit is contained in:
@ -1,25 +1,67 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Auth\User as Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
$factory->define(User::class, function (Faker $faker) {
|
||||
$password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi'; // password
|
||||
class User extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'email' => $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,
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi'; // password
|
||||
|
||||
$factory->state(User::class, 'enabled', ['enabled' => 1]);
|
||||
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,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(User::class, 'disabled', ['enabled' => 0]);
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 0,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user