feat(accounts): tambahkan model dan migrasi untuk tabel akun
- Menambahkan model Account dengan atribut yang dapat diisi. - Menambahkan migrasi untuk membuat tabel accounts dengan kolom yang diperlukan.
This commit is contained in:
31
app/Models/Account.php
Normal file
31
app/Models/Account.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Webstatement\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
// use Modules\Webstatement\Database\Factories\AccountFactory;
|
||||||
|
|
||||||
|
class Account extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'account_number',
|
||||||
|
'customer_code',
|
||||||
|
'currency',
|
||||||
|
'opening_date',
|
||||||
|
'branch_code',
|
||||||
|
'product_category',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
// Relationships
|
||||||
|
public function customer()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Customer::class, 'customer_code', 'customer_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('accounts', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('account_number')->unique();
|
||||||
|
$table->string('customer_code')->nullable();
|
||||||
|
$table->string('currency')->nullable();
|
||||||
|
$table->string('opening_date')->nullable();
|
||||||
|
$table->string('branch_code')->nullable();
|
||||||
|
$table->string('product_category')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('accounts');
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user