Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120824792
SetDiscountCommand.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
SetDiscountCommand.php
View Options
<?php
namespace
App\Console\Commands\Wallet
;
use
App\Console\Command
;
use
App\Discount
;
class
SetDiscountCommand
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'wallet:set-discount {wallet} {discount}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Apply a discount to a wallet'
;
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$wallet
=
$this
->
getWallet
(
$this
->
argument
(
'wallet'
));
if
(!
$wallet
)
{
$this
->
error
(
"Wallet not found."
);
return
1
;
}
// FIXME: Using '0' for delete might be not that obvious
if
(
$this
->
argument
(
'discount'
)
===
'0'
)
{
$wallet
->
discount
()->
dissociate
();
}
else
{
$discount
=
$this
->
getObject
(
Discount
::
class
,
$this
->
argument
(
'discount'
));
if
(!
$discount
)
{
$this
->
error
(
"Discount not found."
);
return
1
;
}
$wallet
->
discount
()->
associate
(
$discount
);
}
$wallet
->
save
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:27 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18740616
Default Alt Text
SetDiscountCommand.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline