50 lines
1.0 KiB
PHP
50 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\WalletTransactionType;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Fillable([
|
|
'wallet_id',
|
|
'type',
|
|
'amount',
|
|
'balance_before',
|
|
'balance_after',
|
|
'description',
|
|
'created_by',
|
|
])]
|
|
class WalletTransaction extends Model
|
|
{
|
|
/**
|
|
* @return BelongsTo<Wallet, $this>
|
|
*/
|
|
public function wallet(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Wallet::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'type' => WalletTransactionType::class,
|
|
'amount' => 'integer',
|
|
'balance_before' => 'integer',
|
|
'balance_after' => 'integer',
|
|
];
|
|
}
|
|
}
|