From 1b8c32a84dbcea86c189e4cc69426572a039151d Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Tue, 18 Feb 2025 16:31:53 +0700 Subject: [PATCH] feat(customers): tambahkan model dan migrasi untuk tabel customers - Menambahkan model Customer dengan relasi ke akun dan cabang. - Membuat migrasi untuk tabel customers dengan kolom yang diperlukan. --- app/Models/Customer.php | 29 ++++++++++++++++ ...25_02_06_072406_create_customers_table.php | 33 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 app/Models/Customer.php create mode 100644 database/migrations/2025_02_06_072406_create_customers_table.php diff --git a/app/Models/Customer.php b/app/Models/Customer.php new file mode 100644 index 0000000..02f2a54 --- /dev/null +++ b/app/Models/Customer.php @@ -0,0 +1,29 @@ +hasMany(Account::class, 'customer_code', 'customer_code'); + } + + public function branch(){ + return $this->belongsTo(Branch::class, 'branch_code', 'code'); + } +} diff --git a/database/migrations/2025_02_06_072406_create_customers_table.php b/database/migrations/2025_02_06_072406_create_customers_table.php new file mode 100644 index 0000000..896857d --- /dev/null +++ b/database/migrations/2025_02_06_072406_create_customers_table.php @@ -0,0 +1,33 @@ +id(); + $table->string('customer_code')->unique(); + $table->string('name')->nullable(); + $table->text('address')->nullable(); + $table->string('branch_code')->nullable(); + $table->string('date_of_birth')->nullable(); + $table->string('email')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('customers'); + } +};