Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F9889294
ListUsers.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
ListUsers.php
View Options
<?php
namespace
App\Console\Commands\Sku
;
use
App\Console\Command
;
class
ListUsers
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'sku:list-users {sku}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'List users with the SKU entitlement.'
;
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$sku
=
$this
->
getObject
(
\App\Sku
::
class
,
$this
->
argument
(
'sku'
),
'title'
);
if
(!
$sku
)
{
$this
->
error
(
"Unable to find the SKU."
);
return
1
;
}
$fn
=
function
(
$entitlement
)
{
$user_id
=
$entitlement
->
user_id
;
if
(
$entitlement
->
entitleable_type
==
\App\User
::
class
)
{
$user_id
=
$entitlement
->
entitleable_id
;
}
return
$user_id
;
};
$users
=
\App\Entitlement
::
select
(
'user_id'
,
'entitleable_id'
,
'entitleable_type'
)
->
join
(
'wallets'
,
'wallets.id'
,
'='
,
'wallet_id'
)
->
where
(
'sku_id'
,
$sku
->
id
)
->
get
()
->
map
(
$fn
)
->
unique
();
// TODO: This whereIn() might not scale
\App\User
::
whereIn
(
'id'
,
$users
)->
orderBy
(
'email'
)->
get
()
->
pluck
(
'email'
)
->
each
(
function
(
$email
,
$key
)
{
$this
->
info
(
$email
);
});
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Aug 21, 1:18 AM (4 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1277330
Default Alt Text
ListUsers.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment