Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2485076
EntitlementsCommand.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
EntitlementsCommand.php
View Options
<?php
namespace
App\Console\Commands\User
;
use
App\Console\Command
;
class
EntitlementsCommand
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'user:entitlements {userid}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
"List a user's entitlements."
;
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$user
=
$this
->
getUser
(
$this
->
argument
(
'userid'
));
if
(!
$user
)
{
$this
->
error
(
"User not found."
);
return
1
;
}
$skus_counted
=
[];
foreach
(
$user
->
entitlements
as
$entitlement
)
{
if
(!
array_key_exists
(
$entitlement
->
sku_id
,
$skus_counted
))
{
$skus_counted
[
$entitlement
->
sku_id
]
=
1
;
}
else
{
$skus_counted
[
$entitlement
->
sku_id
]
+=
1
;
}
}
foreach
(
$skus_counted
as
$id
=>
$qty
)
{
$sku
=
\App\Sku
::
find
(
$id
);
$this
->
info
(
"{$sku->title}: {$qty}"
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Nov 20, 9:10 PM (23 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
387307
Default Alt Text
EntitlementsCommand.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment