![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/clinic.corals.io/database/seeders/ |
<?php namespace Database\Seeders; use App\Models\Doctor; use App\Models\Patient; use App\Models\Specialization; use App\Models\User; use Carbon\Carbon; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\Hash; class DefaultUserSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { $users = [ [ 'first_name' => 'Super', 'last_name' => 'Admin', 'contact' => '1234567890', 'gender' => User::MALE, 'type' => User::ADMIN, 'email' => '[email protected]', 'email_verified_at' => Carbon::now(), 'password' => Hash::make('123456'), 'region_code' => '91', ], [ 'first_name' => 'Adam', 'last_name' => 'Diaz', 'contact' => '1234567890', 'gender' => User::MALE, 'type' => User::DOCTOR, 'email' => '[email protected]', 'email_verified_at' => Carbon::now(), 'password' => Hash::make('123456'), ], [ 'first_name' => 'Aiko', 'last_name' => 'Walsh', 'contact' => '1234567890', 'gender' => User::MALE, 'type' => User::PATIENT, 'email' => '[email protected]', 'email_verified_at' => Carbon::now(), 'password' => Hash::make('123456'), ], ]; foreach ($users as $key => $user) { $user = User::create($user); if ($key == 1) { $doctor = Doctor::create(['user_id' => $user->id]); $user->address()->create(['owner_id' => $user->id]); } if ($key == 2) { $patient = Patient::create(['user_id' => $user->id, 'patient_unique_id' => 'UNIQUE12']); $patient->address()->create(['owner_id' => $patient['user_id']]); } } $specializationIds = Specialization::pluck('id'); $doctor->specializations()->sync($specializationIds); } }