feat(wallets): implement wallet and transaction management with associated models, policies, and resources

This commit is contained in:
2026-06-07 00:18:32 +03:30
parent c2319a55cb
commit d1d42b38d1
23 changed files with 790 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?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',
];
}
}