initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// \App\Models\User::factory(10)->create();
|
||||
|
||||
// \App\Models\User::factory()->create([
|
||||
// 'name' => 'Test User',
|
||||
// 'email' => 'test@example.com',
|
||||
// ]);
|
||||
$this->call([
|
||||
RoleSeeder::class,
|
||||
UserSeeder::class,
|
||||
DoctorSeeder::class,
|
||||
PatientSeeder::class,
|
||||
DiagnoseSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Diagnose;
|
||||
use App\Models\Doctor;
|
||||
use App\Models\Patient;
|
||||
use Illuminate\Database\Seeder;
|
||||
class DiagnoseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$conditions = collect(['normal','mi']);
|
||||
$notes = [
|
||||
'normal' => "kondisi normal, namun perlu istirahat",
|
||||
'mi' => "perlu tindakan secepatnya dan pemantauan"
|
||||
];
|
||||
|
||||
for ($x = 0; $x < 50; $x++){
|
||||
$doctor = Doctor::inRandomOrder()->first();
|
||||
$patient = Patient::inRandomOrder()->first();
|
||||
$c = $conditions->shuffle()->first();
|
||||
Diagnose::create([
|
||||
'patient_id' =>$patient->id,
|
||||
'doctor_id' =>$doctor->id,
|
||||
'diagnoses' => $c,
|
||||
'notes' => $notes[$c],
|
||||
'is_verified' => false,
|
||||
'file' => 'apicta/963q79jNwGT8Pqhs910e1eC57hZbWugnXnbYb2wr.wav'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Doctor;
|
||||
use App\Models\User;
|
||||
use Hash;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DoctorSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$uuids = [
|
||||
'02b68875-5092-387d-8cef-f29a629bbe5e',
|
||||
'18f87aa5-d695-3cdf-92f9-a73328c4b566',
|
||||
'8dba1f8e-75de-37a1-84be-f55dbc55bb0c',
|
||||
];
|
||||
|
||||
for ($x = 1; $x <= 3; $x++) {
|
||||
$user = User::create([
|
||||
'email' => 'doctor' . $x . '@mail.com',
|
||||
'password' => Hash::make('password')
|
||||
]);
|
||||
|
||||
$user->assignRole('doctor');
|
||||
|
||||
$genders = collect(['male','female']);
|
||||
|
||||
Doctor::create([
|
||||
'id' => $uuids[$x - 1],
|
||||
'user_id' => $user->id,
|
||||
'fullname' => fake()->name(),
|
||||
'address' => fake()->address(),
|
||||
'phone' => fake()->phoneNumber(),
|
||||
'emergency_phone' => fake()->phoneNumber(),
|
||||
'gender' => $genders->shuffle()->first(),
|
||||
'age' => 20,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Doctor;
|
||||
use App\Models\Patient;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Hash;
|
||||
|
||||
class PatientSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
for ($x = 1; $x <= 25; $x++){
|
||||
$user = User::create([
|
||||
'email' => 'patient'.$x.'@mail.com',
|
||||
'password' => Hash::make('password')
|
||||
]);
|
||||
|
||||
$user->assignRole('patient');
|
||||
|
||||
$genders = collect(['male','female']);
|
||||
$conditions = collect(['normal','mi']);
|
||||
|
||||
$patient = Patient::create([
|
||||
'id' => fake()->uuid(),
|
||||
'user_id' => $user->id,
|
||||
'fullname' => fake()->name(),
|
||||
'address' => fake()->address(),
|
||||
'phone' => fake()->phoneNumber(),
|
||||
'emergency_phone' => fake()->phoneNumber(),
|
||||
'gender' => $genders->shuffle()->first(),
|
||||
'age' => rand(9,70),
|
||||
'device_id' => fake()->uuid(),
|
||||
'condition' => $conditions->shuffle()->first(),
|
||||
]);
|
||||
}
|
||||
|
||||
$patients = Patient::all();
|
||||
|
||||
foreach ($patients as $p){
|
||||
$doctor = Doctor::inRandomOrder()->first();
|
||||
$p->doctors()->attach($doctor);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Role;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RoleSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private array $roles = [
|
||||
'admin',
|
||||
'patient',
|
||||
'doctor'
|
||||
];
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
|
||||
foreach ($this->roles as $role){
|
||||
\Spatie\Permission\Models\Role::create([
|
||||
'name' => $role,
|
||||
'guard_name' => 'api'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Hash;
|
||||
use App\Models\User;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$admin = User::create([
|
||||
'email' => 'admin@mail.com',
|
||||
'password' => Hash::make('password')
|
||||
]);
|
||||
|
||||
$admin->assignRole('admin');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user