Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117756423
EntitlementsCommand.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
EntitlementsCommand.php
View Options
<?php
namespace
App\Console\Commands\User
;
use
App\Console\Command
;
use
App\Sku
;
class
EntitlementsCommand
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'user:entitlements {user}'
;
/**
* 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
(
'user'
));
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
]++;
}
}
foreach
(
$skus_counted
as
$id
=>
$qty
)
{
$sku
=
Sku
::
find
(
$id
);
$this
->
info
(
"{$sku->title}: {$qty}"
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Apr 4, 8:40 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18740382
Default Alt Text
EntitlementsCommand.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline