Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1841527
PackageSku.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
PackageSku.php
View Options
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
/**
* Link SKUs to Packages.
*
* @property int $cost
* @property string $package_id
* @property \App\Package $package
* @property int $qty
* @property \App\Sku $sku
* @property string $sku_id
*/
class
PackageSku
extends
Pivot
{
protected
$fillable
=
[
'package_id'
,
'sku_id'
,
'cost'
,
'qty'
];
protected
$casts
=
[
'cost'
=>
'integer'
,
'qty'
=>
'integer'
];
/**
* Under this package, how much does this SKU cost?
*
* @return int The costs of this SKU under this package in cents.
*/
public
function
cost
()
{
$units
=
$this
->
qty
-
$this
->
sku
->
units_free
;
if
(
$units
<
0
)
{
$units
=
0
;
}
// FIXME: Why package_skus.cost value is not used anywhere?
$ppu
=
$this
->
sku
->
cost
*
((
100
-
$this
->
package
->
discount_rate
)
/
100
);
return
$units
*
$ppu
;
}
/**
* Under this package, what fee this SKU has?
*
* @return int The fee for this SKU under this package in cents.
*/
public
function
fee
()
{
$units
=
$this
->
qty
-
$this
->
sku
->
units_free
;
if
(
$units
<
0
)
{
$units
=
0
;
}
return
$this
->
sku
->
fee
*
$units
;
}
/**
* The package for this relation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public
function
package
()
{
return
$this
->
belongsTo
(
'App
\P
ackage'
);
}
/**
* The SKU for this relation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public
function
sku
()
{
return
$this
->
belongsTo
(
'App
\S
ku'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Aug 25, 3:20 PM (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
220429
Default Alt Text
PackageSku.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment