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.
This commit is contained in:
Daeng Deni Mardaeni
2025-02-18 16:31:53 +07:00
parent 3986b35c25
commit 1b8c32a84d
2 changed files with 62 additions and 0 deletions

29
app/Models/Customer.php Normal file
View File

@@ -0,0 +1,29 @@
<?php
namespace Modules\Webstatement\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Basicdata\Models\Branch;
class Customer extends Model
{
use HasFactory;
protected $fillable = [
'customer_code',
'name',
'address',
'branch_code',
'date_of_birth',
'email',
];
public function accounts(){
return $this->hasMany(Account::class, 'customer_code', 'customer_code');
}
public function branch(){
return $this->belongsTo(Branch::class, 'branch_code', 'code');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('customers', function (Blueprint $table) {
$table->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');
}
};