Files
MKM/app/Models/Transaction.php
Jp 207f4c1609 feat(client): add financial reports and ledger management
- Add trial balance and general ledger pages to client resource with interactive tables
- Implement sales and expenses relation managers for client-specific transactions
- Enhance transaction handling with proper tax and withholding calculations
- Add date casting to Transaction model and define client relationships
- Configure super admin role bypass in AppServiceProvider
- Update Filament components and fix JavaScript formatting issues
2026-02-09 16:20:55 +08:00

55 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\MorphTo;
class Transaction extends Model
{
use HasFactory;
protected $guarded = [];
protected $casts = [
'happened_on' => 'date',
];
public function transactionable(): MorphTo
{
return $this->morphTo();
}
/**
* Get the account that owns the Transaction
*/
public function account(): BelongsTo
{
return $this->belongsTo(Account::class);
}
public function getAccountTypeAttribute(): string
{
return $this->account->type;
}
/**
* Get the ledgers associated with the Transaction
*
* @return HasOne
*/
public function ledgers(): HasMany
{
return $this->hasMany(Ledger::class);
}
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class);
}
}