feat(wallets): implement wallet and transaction management with associated models, policies, and resources
This commit is contained in:
29
app/Policies/WalletPolicy.php
Normal file
29
app/Policies/WalletPolicy.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class WalletPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $this->canManage($user);
|
||||
}
|
||||
|
||||
public function view(User $user, Wallet $wallet): bool
|
||||
{
|
||||
return $this->canManage($user);
|
||||
}
|
||||
|
||||
public function update(User $user, Wallet $wallet): bool
|
||||
{
|
||||
return $this->canManage($user);
|
||||
}
|
||||
|
||||
private function canManage(User $user): bool
|
||||
{
|
||||
return $user->hasRole('admin') || $user->hasPermission('wallets.manage');
|
||||
}
|
||||
}
|
||||
24
app/Policies/WalletTransactionPolicy.php
Normal file
24
app/Policies/WalletTransactionPolicy.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\WalletTransaction;
|
||||
|
||||
class WalletTransactionPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $this->canManage($user);
|
||||
}
|
||||
|
||||
public function view(User $user, WalletTransaction $transaction): bool
|
||||
{
|
||||
return $this->canManage($user);
|
||||
}
|
||||
|
||||
private function canManage(User $user): bool
|
||||
{
|
||||
return $user->hasRole('admin') || $user->hasPermission('wallets.manage');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user