Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2.  
  3. use App\Models\Organization;
  4. use App\Models\User;
  5. use Carbon\Carbon;
  6. use Illuminate\Database\Seeder;
  7. use Illuminate\Support\Facades\Hash;
  8.  
  9. class AdminUserSeeder extends Seeder
  10. {
  11.     public function run() : void
  12.     {
  13.         /** @var Organization $organization */
  14.         $organization = Organization::firstOrCreate(
  15.             [
  16.                 'name'           => 'PIA',
  17.                 'email_domain'   => 'admin.com',
  18.                 'zip_code'       => '10125',
  19.                 'city'           => 'Berlin',
  20.                 'street'         => 'Chausseestrasse',
  21.                 'address_number' => '16',
  22.             ]
  23.         );
  24.  
  25.         /** @var User $user */
  26.         $user = $organization->users()->firstOrCreate([
  27.             'first_name'               => 'Admin',
  28.             'last_name'                => 'PIA',
  29.             'email'                    => 'admin@admin.com',
  30.             'password'                 => Hash::make('Password123'),
  31.             'status'                   => true,
  32.             'email_verified_at'        => new Carbon(),
  33.             'email_verification_token' => null,
  34.         ]);
  35.  
  36.         $user->assignRole(User::ROLE_ADMIN);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement