40 lines
996 B
PHP
40 lines
996 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\HasUuid;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
#[Fillable(['wallet_id', 'type', 'amount', 'balance_before', 'balance_after', 'source_type', 'source_id', 'idempotency_key', 'metadata'])]
|
|
class WalletTransaction extends Model
|
|
{
|
|
use HasUuid;
|
|
|
|
public const UPDATED_AT = null;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'type' => 'string',
|
|
'amount' => 'decimal:2',
|
|
'balance_before' => 'decimal:2',
|
|
'balance_after' => 'decimal:2',
|
|
'metadata' => 'array',
|
|
'created_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function wallet(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Wallet::class);
|
|
}
|
|
|
|
public function source(): MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
}
|