Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120826130
Entitlement.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
Entitlement.php
View Options
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
/**
The eloquent definition of an entitlement.
Owned by a {@link \App\User}, billed to a {@link \App\Wallet}.
*/
class
Entitlement
extends
Model
{
public
$incrementing
=
false
;
protected
$keyType
=
'string'
;
protected
$fillable
=
[
'sku_id'
,
'owner_id'
,
'user_id'
,
'wallet_id'
,
'description'
];
/**
Provide a custom ID (uuid) property.
@return void
*/
protected
static
function
boot
()
{
parent
::
boot
();
static
::
creating
(
function
(
$entitlement
)
{
$entitlement
->{
$entitlement
->
getKeyName
()}
=
\App\Utils
::
uuidStr
();
// Make sure the owner is at least a controller on the wallet
$owner
=
\App\User
::
find
(
$entitlement
->
owner_id
);
$wallet
=
\App\Wallet
::
find
(
$entitlement
->
wallet_id
);
if
(!
$owner
)
{
return
false
;
}
if
(!
$wallet
)
{
return
false
;
}
if
(!
$wallet
->
owner
()
==
$owner
)
{
if
(!
$wallet
->
controllers
->
contains
(
$owner
))
{
return
false
;
}
}
$sku
=
\App\Sku
::
find
(
$entitlement
->
sku_id
);
if
(!
$sku
)
{
return
false
;
}
$wallet
->
debit
(
$sku
->
cost
);
}
);
}
/**
The SKU concerned.
@return Sku
*/
public
function
sku
()
{
return
$this
->
belongsTo
(
'App
\S
ku'
);
}
/**
The owner of this entitlement.
@return User
*/
public
function
owner
()
{
return
$this
->
belongsTo
(
'App
\U
ser'
,
'owner_id'
);
}
/**
The target user for this entitlement
@return User
*/
public
function
user
()
{
return
$this
->
belongsTo
(
'App
\U
ser'
);
}
/**
The wallet this entitlement is being billed to
@return Wallet
*/
public
function
wallet
()
{
return
$this
->
belongsTo
(
'App
\W
allet'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:49 AM (6 d, 20 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18734559
Default Alt Text
Entitlement.php (2 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline