Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117881450
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
11 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/app/Console/Commands/Wallet/AddAwardTransactionCommand.php b/src/app/Console/Commands/Wallet/AddAwardTransactionCommand.php
new file mode 100644
index 00000000..fbc4e369
--- /dev/null
+++ b/src/app/Console/Commands/Wallet/AddAwardTransactionCommand.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace App\Console\Commands\Wallet;
+
+use Illuminate\Console\Command;
+
+class AddAwardTransactionCommand extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'wallet:add-award {wallet} {cents} {--message=}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Add an award to a wallet';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $wallet = \App\Wallet::find($this->argument('wallet'));
+
+ if (!$wallet) {
+ return 1;
+ }
+
+ $cents = (int) $this->argument('cents');
+
+ if ($cents < 0) {
+ $this->error("Can't award a negative amount.");
+ return 1;
+ }
+
+ if (!$this->option('message')) {
+ $this->error("Can't award without a message.");
+ return 1;
+ }
+
+ $message = $this->option('message');
+
+ $wallet->balance += $cents;
+ $wallet->save();
+
+ \App\Transaction::create(
+ [
+ 'object_id' => $wallet->id,
+ 'object_type' => \App\Wallet::class,
+ 'type' => \App\Transaction::WALLET_AWARD,
+ 'amount' => $cents
+ ]
+ );
+ }
+}
diff --git a/src/app/Console/Commands/Wallet/AddCreditTransactionCommand.php b/src/app/Console/Commands/Wallet/AddCreditTransactionCommand.php
new file mode 100644
index 00000000..eb091fa0
--- /dev/null
+++ b/src/app/Console/Commands/Wallet/AddCreditTransactionCommand.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace App\Console\Commands\Wallet;
+
+use Illuminate\Console\Command;
+
+class AddCreditTransactionCommand extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'wallet:add-credit {wallet} {cents} {--message=}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Add a number of cents to a wallet';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $wallet = \App\Wallet::find($this->argument('wallet'));
+
+ if (!$wallet) {
+ return 1;
+ }
+
+ $cents = (int) $this->argument('cents');
+
+ if ($cents < 0) {
+ $this->error("Can't credit a negative amount. Did you mean to use debit?");
+ return 1;
+ }
+
+ if (!$this->option('message')) {
+ $this->error("Can't manually credit without a message.");
+ return 1;
+ }
+
+ $message = $this->option('message');
+
+ $wallet->balance += $cents;
+ $wallet->save();
+
+ \App\Transaction::create(
+ [
+ 'object_id' => $wallet->id,
+ 'object_type' => \App\Wallet::class,
+ 'type' => \App\Transaction::WALLET_CREDIT,
+ 'amount' => $cents
+ ]
+ );
+ }
+}
diff --git a/src/app/Console/Commands/Wallet/AddDebitTransactionCommand.php b/src/app/Console/Commands/Wallet/AddDebitTransactionCommand.php
new file mode 100644
index 00000000..26375584
--- /dev/null
+++ b/src/app/Console/Commands/Wallet/AddDebitTransactionCommand.php
@@ -0,0 +1,73 @@
+<?php
+
+namespace App\Console\Commands\Wallet;
+
+use Illuminate\Console\Command;
+
+class AddDebitTransactionCommand extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'wallet:add-debit {wallet} {cents} {--message=}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Add a debit transaction to a wallet ' .
+ '(deduct a positive quantity of cents)';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $wallet = \App\Wallet::find($this->argument('wallet'));
+
+ if (!$wallet) {
+ return 1;
+ }
+
+ $cents = (int) $this->argument('cents');
+
+ if ($cents < 0) {
+ $this->error("Can't debit a negative amount. Did you mean to use credit?");
+ return 1;
+ }
+
+ if (!$this->option('message')) {
+ $this->error("Can't debit a wallet without a message.");
+ return 1;
+ }
+
+ $message = $this->option('message');
+
+ $wallet->balance -= $cents;
+ $wallet->save();
+
+ \App\Transaction::create(
+ [
+ 'object_id' => $wallet->id,
+ 'object_type' => \App\Wallet::class,
+ 'type' => \App\Transaction::WALLET_DEBIT,
+ 'amount' => $cents
+ ]
+ );
+ }
+}
diff --git a/src/app/Console/Commands/Wallet/AddPenaltyTransactionCommand.php b/src/app/Console/Commands/Wallet/AddPenaltyTransactionCommand.php
new file mode 100644
index 00000000..16374d55
--- /dev/null
+++ b/src/app/Console/Commands/Wallet/AddPenaltyTransactionCommand.php
@@ -0,0 +1,73 @@
+<?php
+
+namespace App\Console\Commands\Wallet;
+
+use Illuminate\Console\Command;
+
+class AddPenaltyTransactionCommand extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'wallet:add-penalty {wallet} {cents} {--message=}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Add a penalty transaction to a wallet ' .
+ '(deduct a positive quantity of cents)';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $wallet = \App\Wallet::find($this->argument('wallet'));
+
+ if (!$wallet) {
+ return 1;
+ }
+
+ $cents = (int) $this->argument('cents');
+
+ if ($cents < 0) {
+ $this->error("Can't penalize with a negative amount.");
+ return 1;
+ }
+
+ if (!$this->option('message')) {
+ $this->error("Can't penalize a wallet without a message.");
+ return 1;
+ }
+
+ $message = $this->option('message');
+
+ $wallet->balance -= $cents;
+ $wallet->save();
+
+ \App\Transaction::create(
+ [
+ 'object_id' => $wallet->id,
+ 'object_type' => \App\Wallet::class,
+ 'type' => \App\Transaction::WALLET_PENALTY,
+ 'amount' => $cents
+ ]
+ );
+ }
+}
diff --git a/src/app/Console/Commands/WalletTransactions.php b/src/app/Console/Commands/Wallet/ListTransactionsCommand.php
similarity index 90%
rename from src/app/Console/Commands/WalletTransactions.php
rename to src/app/Console/Commands/Wallet/ListTransactionsCommand.php
index 3be8872d..47e8545f 100644
--- a/src/app/Console/Commands/WalletTransactions.php
+++ b/src/app/Console/Commands/Wallet/ListTransactionsCommand.php
@@ -1,72 +1,72 @@
<?php
-namespace App\Console\Commands;
+namespace App\Console\Commands\Wallet;
use Illuminate\Console\Command;
-class WalletTransactions extends Command
+class ListTransactionsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
- protected $signature = 'wallet:transactions {--detail} {wallet}';
+ protected $signature = 'wallet:list-transactions {--detail} {wallet}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'List the transactions against a wallet.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$wallet = \App\Wallet::where('id', $this->argument('wallet'))->first();
if (!$wallet) {
return 1;
}
foreach ($wallet->transactions()->orderBy('created_at')->get() as $transaction) {
$this->info(
sprintf(
"%s: %s %s",
$transaction->id,
$transaction->created_at,
$transaction->toString()
)
);
if ($this->option('detail')) {
$elements = \App\Transaction::where('transaction_id', $transaction->id)
->orderBy('created_at')->get();
foreach ($elements as $element) {
$this->info(
sprintf(
" + %s: %s",
$element->id,
$element->toString()
)
);
}
}
}
}
}
diff --git a/src/app/Console/Commands/WalletAddTransaction.php b/src/app/Console/Commands/WalletAddTransaction.php
deleted file mode 100644
index 445c9652..00000000
--- a/src/app/Console/Commands/WalletAddTransaction.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use Illuminate\Console\Command;
-
-class WalletAddTransaction extends Command
-{
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'wallet:add-transaction {wallet} {qty} {--message=}';
-
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Add a transaction to a wallet';
-
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
-
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $wallet = \App\Wallet::find($this->argument('wallet'));
-
- if (!$wallet) {
- return 1;
- }
-
- $qty = (int) $this->argument('qty');
-
- $message = $this->option('message');
-
- if ($qty < 0) {
- $wallet->debit($qty, $message);
- } else {
- $wallet->credit($qty, $message);
- }
- }
-}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Apr 5, 11:55 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18831637
Default Alt Text
(11 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline