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:
29
app/Models/Customer.php
Normal file
29
app/Models/Customer.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user