Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120824596
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\User
;
use
App\Console\Command
;
class
SetDiscountCommand
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'user:set-discount {user} {discount}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
"Apply a discount to all of the user's wallets"
;
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$user
=
$this
->
getUser
(
$this
->
argument
(
'user'
));
if
(!
$user
)
{
$this
->
error
(
"User not found."
);
return
1
;
}
if
(
$this
->
argument
(
'discount'
)
===
'0'
)
{
$discount
=
null
;
}
else
{
$discount
=
$this
->
getObject
(
\App\Discount
::
class
,
$this
->
argument
(
'discount'
));
if
(!
$discount
)
{
$this
->
error
(
"Discount not found."
);
return
1
;
}
}
foreach
(
$user
->
wallets
as
$wallet
)
{
if
(!
$discount
)
{
$wallet
->
discount
()->
dissociate
();
}
else
{
$wallet
->
discount
()->
associate
(
$discount
);
}
$wallet
->
save
();
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:24 AM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18809913
Default Alt Text
SetDiscountCommand.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline