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

39
app/Models/Wallet.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['user_id', 'balance', 'is_active'])]
class Wallet extends Model
{
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @return HasMany<WalletTransaction, $this>
*/
public function transactions(): HasMany
{
return $this->hasMany(WalletTransaction::class)->latest();
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'balance' => 'integer',
'is_active' => 'boolean',
];
}
}