- Add Enums: TransactionType, TransactionStatus, PaymentGateway - Migrations: wallets, wallet_transactions, wallet_activity_logs - Models: Wallet, WalletTransaction, WalletActivityLog - Services: WalletService with complete business logic - Controllers: WalletController, PaymentController - Filament Resources: WalletResource, WalletTransactionResource - Artisan Command: ifnex:token for API token generation - Sanctum integration with statefulApi and exception handling - Full API endpoints: balance, transactions, admin-adjust, freeze/unfreeze
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class WalletActivityLog extends Model
|
|
{
|
|
protected $fillable = [
|
|
'wallet_id',
|
|
'user_id',
|
|
'action',
|
|
'description',
|
|
'old_values',
|
|
'new_values',
|
|
'ip_address',
|
|
'user_agent',
|
|
];
|
|
|
|
protected $casts = [
|
|
'old_values' => 'array',
|
|
'new_values' => 'array',
|
|
];
|
|
|
|
public function wallet(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Wallet::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public static function log(
|
|
Wallet $wallet,
|
|
string $action,
|
|
?string $description = null,
|
|
?array $oldValues = null,
|
|
?array $newValues = null,
|
|
?User $user = null
|
|
): self {
|
|
return self::create([
|
|
'wallet_id' => $wallet->id,
|
|
'user_id' => $user?->id ?? auth()->id(),
|
|
'action' => $action,
|
|
'description' => $description,
|
|
'old_values' => $oldValues,
|
|
'new_values' => $newValues,
|
|
'ip_address' => request()->ip(),
|
|
'user_agent' => request()->userAgent(),
|
|
]);
|
|
}
|
|
} |