Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120826664
Plan.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
Plan.php
View Options
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
/**
* The eloquent definition of a Plan.
*
* A Plan is a grouping of packages, such as a "Family Plan".
*
* A "Family Plan" as such may exist of "2 or more Kolab packages",
* and apply a discount for the third and further Kolab packages.
*/
class
Plan
extends
Model
{
use
\Spatie\Translatable\HasTranslations
;
public
$incrementing
=
false
;
protected
$keyType
=
'string'
;
public
$timestamps
=
false
;
protected
$fillable
=
[
'title'
,
'name'
,
'description'
,
// a start and end datetime for this promotion
'promo_from'
,
'promo_to'
,
// discounts start at this quantity
'discount_qty'
,
// the rate of the discount for this plan
'discount_rate'
,
];
protected
$casts
=
[
'promo_from'
=>
'datetime'
,
'promo_to'
=>
'datetime'
,
'discount_qty'
=>
'integer'
,
'discount_rate'
=>
'integer'
];
/** @var array Translatable properties */
public
$translatable
=
[
'name'
,
'description'
,
];
public
function
cost
()
{
$costs
=
0
;
foreach
(
$this
->
packages
as
$package
)
{
$costs
+=
$package
->
pivot
->
cost
();
}
return
$costs
;
}
public
function
packages
()
{
return
$this
->
belongsToMany
(
'App
\P
ackage'
,
'plan_packages'
)->
using
(
'App
\P
lanPackage'
)->
withPivot
(
[
'qty_min'
,
'qty_max'
,
'discount_qty'
,
'discount_rate'
]
);
}
/**
* Checks if the plan has domain SKU assigned
*/
public
function
hasDomain
():
bool
{
foreach
(
$this
->
packages
as
$package
)
{
foreach
(
$package
->
skus
as
$sku
)
{
if
(
$sku
->
handler_class
::
entitleableClass
()
==
\App\Domain
::
class
)
{
return
true
;
}
}
}
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:58 AM (1 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
36/d3/078f5893046d50ff20a162da7d50
Default Alt Text
Plan.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline