Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120837722
PackageSku.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
PackageSku.php
View Options
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
/**
* Link SKUs to Packages.
*/
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
()
{
$costs
=
0
;
$units
=
$this
->
qty
-
$this
->
sku
->
units_free
;
if
(
$units
<
0
)
{
\Log
::
debug
(
"Package {$this->package_id} is misconfigured for more free units than qty."
);
$units
=
0
;
}
$ppu
=
$this
->
sku
->
cost
*
((
100
-
$this
->
package
->
discount_rate
)
/
100
);
$costs
+=
$units
*
$ppu
;
return
$costs
;
}
public
function
package
()
{
return
$this
->
belongsTo
(
'App
\P
ackage'
);
}
public
function
sku
()
{
return
$this
->
belongsTo
(
'App
\S
ku'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 1:48 PM (3 d, 20 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
64/91/4f6f15c5ad00b21682fe9db2669c
Default Alt Text
PackageSku.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline