Server IP : 66.29.132.124 / Your IP : 13.59.236.101 Web Server : LiteSpeed System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : wavevlvu ( 1524) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/wavevlvu/book24.ng/vendor/bavix/laravel-wallet/src/Objects/ |
Upload File : |
<?php namespace Bavix\Wallet\Objects; use Bavix\Wallet\Interfaces\Mathable; use Bavix\Wallet\Interfaces\Wallet; use Bavix\Wallet\Models\Transaction; use Ramsey\Uuid\Uuid; class Operation { /** * @var string */ protected $type; /** * @var string */ protected $uuid; /** * @var int */ protected $amount; /** * @var null|array */ protected $meta; /** * @var bool */ protected $confirmed; /** * @var Wallet */ protected $wallet; /** * Transaction constructor. * * @throws */ public function __construct() { $this->uuid = Uuid::uuid4()->toString(); } /** * @return string */ public function getType(): string { return $this->type; } /** * @return string */ public function getUuid(): string { return $this->uuid; } /** * @return float|int */ public function getAmount() { return $this->amount; } /** * @return array|null */ public function getMeta(): ?array { return $this->meta; } /** * @return bool */ public function isConfirmed(): bool { return $this->confirmed; } /** * @param string $type * * @return static */ public function setType(string $type): self { $this->type = $type; return $this; } /** * @param int|string $amount * * @return static */ public function setAmount($amount): self { $this->amount = app(Mathable::class)->round($amount); return $this; } /** * @param array|null $meta * * @return static */ public function setMeta(?array $meta): self { $this->meta = $meta; return $this; } /** * @param bool $confirmed * * @return static */ public function setConfirmed(bool $confirmed): self { $this->confirmed = $confirmed; return $this; } /** * @return Wallet */ public function getWallet(): Wallet { return $this->wallet; } /** * @param Wallet $wallet * * @return static */ public function setWallet(Wallet $wallet): self { $this->wallet = $wallet; return $this; } /** * @return Transaction */ public function create(): Transaction { /** * @var Transaction $model */ $model = $this->getWallet() ->transactions() ->create($this->toArray()); return $model; } /** * @return array * * @throws */ public function toArray(): array { return [ 'type' => $this->getType(), 'wallet_id' => $this->getWallet()->getKey(), 'uuid' => $this->getUuid(), 'confirmed' => $this->isConfirmed(), 'amount' => $this->getAmount(), 'meta' => $this->getMeta(), ]; } }