fix: adjust migration & seeder

This commit is contained in:
Nawcodes 2025-04-26 17:37:41 +07:00
parent 2a982057d7
commit 563d61c296
16 changed files with 24 additions and 8 deletions

View File

@ -8,6 +8,5 @@ class MsAsuransi extends Model
{
protected $table = 'ms_asuransi';
protected $primaryKey = 'id_asuransi';
protected $keyType = 'string';
protected $guarded = [];
}

View File

@ -8,6 +8,7 @@ class TrRegistrasi extends Model
{
protected $table = 'tr_registrasi';
protected $primaryKey = 'id_registrasi';
protected $keyType = 'string';
protected $guarded = [];
public function pasien()

View File

@ -8,6 +8,7 @@ class TrTransaksi extends Model
{
protected $table = 'tr_transaksi';
protected $primaryKey = 'id_transaksi';
protected $keyType = 'string';
protected $guarded = [];
protected $casts = [
'id_tindakan' => 'array',

View File

@ -12,8 +12,9 @@ return new class extends Migration
public function up(): void
{
Schema::create('ms_asuransi', function (Blueprint $table) {
$table->string('id_asuransi')->primary();
$table->id('id_asuransi');
$table->string('nama_asuransi');
$table->string('keterangan')->nullable();
$table->timestamps();
});
}

View File

@ -14,6 +14,10 @@ return new class extends Migration
Schema::create('ms_pegawai', function (Blueprint $table) {
$table->string('id_pegawai')->primary();
$table->string('nama_pegawai');
$table->string('no_hp');
$table->string('email');
$table->string('alamat');
$table->string('jabatan');
$table->timestamps();
});
}

View File

@ -14,6 +14,7 @@ return new class extends Migration
Schema::create('ms_ruang_pelayanan', function (Blueprint $table) {
$table->string('id_ruang_pelayanan')->primary();
$table->string('nama_ruang_pelayanan');
$table->string('keterangan')->nullable();
$table->timestamps();
});
}

View File

@ -15,6 +15,7 @@ return new class extends Migration
$table->string('id_tindakan')->primary();
$table->string('nama_tindakan');
$table->decimal('tarif_tindakan', 12, 2);
$table->string('keterangan')->nullable();
$table->timestamps();
});
}

View File

@ -12,10 +12,10 @@ return new class extends Migration
public function up(): void
{
Schema::create('tr_registrasi', function (Blueprint $table) {
$table->id('id_registrasi');
$table->string('id_registrasi')->primary();
$table->date('tgl_registrasi');
$table->unsignedBigInteger('mr_pasien');
$table->string('id_asuransi')->nullable();
$table->unsignedBigInteger('id_asuransi')->nullable();
$table->string('id_pegawai');
$table->string('id_ruang_pelayanan');
$table->string('nomor_kartu_asuransi')->nullable();

View File

@ -12,8 +12,8 @@ return new class extends Migration
public function up(): void
{
Schema::create('tr_transaksi', function (Blueprint $table) {
$table->id('id_transaksi');
$table->unsignedBigInteger('id_registrasi');
$table->string('id_transaksi')->primary();
$table->string('id_registrasi');
// id tindakan as array cause has multiple tindakan
$table->json('id_tindakan');
$table->string('id_pegawai');

View File

@ -13,7 +13,7 @@ return new class extends Migration
{
Schema::create('tr_pembayaran', function (Blueprint $table) {
$table->id('id_pembayaran');
$table->unsignedBigInteger('id_registrasi');
$table->string('id_registrasi');
$table->date('tgl_pembayaran');
$table->decimal('total_tagihan', 12, 2);
$table->decimal('jumlah_bayar', 12, 2);

View File

@ -17,8 +17,8 @@ class AsuransiSeeder extends Seeder
foreach (range(1, 10) as $i) {
DB::table('ms_asuransi')->insert([
'id_asuransi' => 'ASUR-' . $faker->unique()->randomNumber(8),
'nama_asuransi' => 'Asuransi ' . $faker->word,
'keterangan' => $faker->sentence,
'created_at' => now(),
'updated_at' => now(),
]);

View File

@ -19,6 +19,10 @@ class PegawaiSeeder extends Seeder
DB::table('ms_pegawai')->insert([
'id_pegawai' => 'PGW-' . $faker->unique()->randomNumber(8),
'nama_pegawai' => $faker->name,
'no_hp' => $faker->phoneNumber,
'email' => $faker->email,
'alamat' => $faker->address,
'jabatan' => $faker->jobTitle,
'created_at' => now(),
'updated_at' => now(),
]);

View File

@ -21,6 +21,7 @@ class RegisterSeeder extends Seeder
for ($i = 0; $i < 10; $i++) {
TrRegistrasi::create([
'id_registrasi' => 'REG-' . $faker->unique()->randomNumber(8),
'tgl_registrasi' => $faker->date(),
'mr_pasien' => MsPasien::all()->random()->mr_pasien,
'id_asuransi' => MsAsuransi::all()->random()->id_asuransi,

View File

@ -19,6 +19,7 @@ class RuangPelayananSeeder extends Seeder
DB::table('ms_ruang_pelayanan')->insert([
'id_ruang_pelayanan' => 'RPL-' . $faker->unique()->randomNumber(8),
'nama_ruang_pelayanan' => 'Ruang ' . $faker->word,
'keterangan' => $faker->sentence,
'created_at' => now(),
'updated_at' => now(),
]);

View File

@ -20,6 +20,7 @@ class TindakanSeeder extends Seeder
'id_tindakan' => 'TIN-' . $faker->unique()->randomNumber(8),
'nama_tindakan' => 'Tindakan ' . $faker->word,
'tarif_tindakan' => $faker->randomFloat(2, 50000, 500000),
'keterangan' => $faker->sentence,
'created_at' => now(),
'updated_at' => now(),
]);

View File

@ -33,6 +33,7 @@ class TransaksiSeed extends Seeder
foreach (range(1, 10) as $i) {
TrTransaksi::create([
'id_transaksi' => 'TRX-' . $faker->unique()->randomNumber(8),
'id_registrasi' => TrRegistrasi::all()->random()->id_registrasi,
'id_tindakan' => $id_tindakan[array_rand($id_tindakan)],
'id_pegawai' => MsPegawai::all()->random()->id_pegawai,