From d0adff2058cd6fbc297390fcb310b751f7c12666 Mon Sep 17 00:00:00 2001 From: Abdullah Al-Faqeir Date: Wed, 6 Oct 2021 16:57:52 +0300 Subject: [PATCH] - Use laravel default UserFactory file. --- database/factories/UserFactory.php | 49 ++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 9279a5d40..3afecc955 100755 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -2,23 +2,46 @@ namespace Database\Factories; -/* -|-------------------------------------------------------------------------- -| Model Factories -|-------------------------------------------------------------------------- -| -| This directory should contain each of the model factory definitions for -| your application. Factories provide a convenient way to generate new -| model instances for testing / seeding your application's database. -| -*/ - +use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; +use Illuminate\Support\Str; class UserFactory extends Factory { - public function definition(): array + /** + * 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() { - return []; + return [ + 'name' => $this->faker->name(), + 'email' => $this->faker->unique()->safeEmail(), + 'email_verified_at' => now(), + 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password + 'remember_token' => Str::random(10), + ]; + } + + /** + * Indicate that the model's email address should be unverified. + * + * @return \Illuminate\Database\Eloquent\Factories\Factory + */ + public function unverified() + { + return $this->state(function (array $attributes) { + return [ + 'email_verified_at' => null, + ]; + }); } } \ No newline at end of file