Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120834447
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.
*
* @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
()
{
$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:03 PM (1 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
37/ac/f7f6374e504f0ed7c82ed7c347a7
Default Alt Text
PackageSku.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline