You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
<?php
|
|
|
|
namespace App\Domains\Accounting\Models;
|
|
|
|
use App\Domains\Accounting\Enums\Ledger\AccountBalance;
|
|
use App\Domains\Accounting\Enums\Ledger\AccountClassification;
|
|
use App\Domains\Accounting\Policies\ChartOfAccountPolicy;
|
|
use App\Domains\System\Traits\Model\HasPublicUlid;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\UsePolicy;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
#[Fillable([
|
|
'code',
|
|
'name',
|
|
'classification',
|
|
'normal_balance',
|
|
'parent_id',
|
|
])]
|
|
#[UsePolicy(ChartOfAccountPolicy::class)]
|
|
class ChartOfAccount extends Model
|
|
{
|
|
use HasPublicUlid;
|
|
|
|
protected $casts = [
|
|
'classification' => AccountClassification::class,
|
|
'normal_balance' => AccountBalance::class,
|
|
];
|
|
|
|
public function parent(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ChartOfAccount::class, 'parent_id');
|
|
}
|
|
|
|
public function children(): HasMany
|
|
{
|
|
return $this->hasMany(ChartOfAccount::class, 'parent_id');
|
|
}
|
|
}
|
|
|
|
|