mirror of
https://github.com/bitinflow/accounts.git
synced 2026-10-31 20:59:06 +00:00
Create Wallets.php
This commit is contained in:
1 parent
4fdbe165bc
commit
91bdad593f
1 file changed
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Bitinflow\Accounts\Traits\BitinflowPaymentsWallet;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class Wallets
|
||||
{
|
||||
public function __construct(protected User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all wallets that belongs to the user.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function get(): ?array
|
||||
{
|
||||
return $this->user->getPaymentsUser()->data->wallets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has an active wallet.
|
||||
*
|
||||
* @return bool
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function has(): ?bool
|
||||
{
|
||||
return $this->user->getPaymentsUser()->data->has_wallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default wallet to given wallet token.
|
||||
*
|
||||
* @param string $token default payment method token
|
||||
* @return bool
|
||||
*/
|
||||
public function setDefault(string $token): bool
|
||||
{
|
||||
$this->user->asPaymentsUser('PUT', sprintf('wallets/default', [
|
||||
'token' => $token
|
||||
]));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user