Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117751335
UserDiscount.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
UserDiscount.php
View Options
<?php
namespace
App\Console\Commands
;
use
Illuminate\Console\Command
;
class
UserDiscount
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'user:discount {user} {discount}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
"Apply a discount to all of the user's wallets"
;
/**
* Create a new command instance.
*
* @return void
*/
public
function
__construct
()
{
parent
::
__construct
();
}
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$user
=
\App\User
::
where
(
'email'
,
$this
->
argument
(
'user'
))->
first
();
if
(!
$user
)
{
return
1
;
}
$this
->
info
(
"Found user {$user->id}"
);
if
(
$this
->
argument
(
'discount'
)
===
'0'
)
{
$discount
=
null
;
}
else
{
$discount
=
\App\Discount
::
find
(
$this
->
argument
(
'discount'
));
if
(!
$discount
)
{
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
Sat, Apr 4, 3:03 AM (2 d, 8 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4c/d5/cbff688866d0cd06d07584d81e15
Default Alt Text
UserDiscount.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline