Advertisement
soden

Untitled

Nov 26th, 2022
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | Source Code | 0 0
  1. <?php
  2.  
  3. namespace Database\Factories;
  4.  
  5. use Illuminate\Database\Eloquent\Factories\Factory;
  6. use Illuminate\Support\Str;
  7.  
  8. /**
  9.  * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
  10.  */
  11. class UserFactory extends Factory
  12. {
  13.     /**
  14.      * Define the model's default state.
  15.      *
  16.      * @return array<string, mixed>
  17.      */
  18.     public function definition()
  19.     {
  20.         return [
  21.             'name' => fake()->name(),
  22.             'email' => fake()->unique()->safeEmail(),
  23.             'email_verified_at' => now(),
  24.             'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
  25.             // tambahkan baris diawah ini
  26.             'role_id' => mt_rand(1, 2),
  27.             'remember_token' => Str::random(10),
  28.         ];
  29.     }
  30.  
  31.     /**
  32.      * Indicate that the model's email address should be unverified.
  33.      *
  34.      * @return static
  35.      */
  36.     public function unverified()
  37.     {
  38.         return $this->state(fn (array $attributes) => [
  39.             'email_verified_at' => null,
  40.         ]);
  41.     }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement