Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1842125
Discount.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
Discount.php
View Options
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
use
Spatie\Translatable\HasTranslations
;
/**
* The eloquent definition of a Discount.
*/
class
Discount
extends
Model
{
use
HasTranslations
;
public
$incrementing
=
false
;
protected
$keyType
=
'string'
;
protected
$casts
=
[
'discount'
=>
'integer'
,
];
protected
$fillable
=
[
'active'
,
'code'
,
'description'
,
'discount'
,
];
/** @var array Translatable properties */
public
$translatable
=
[
'description'
,
];
/**
* Discount value mutator
*
* @throws \Exception
*/
public
function
setDiscountAttribute
(
$discount
)
{
$discount
=
(
int
)
$discount
;
if
(
$discount
<
0
)
{
\Log
::
warning
(
"Expecting a discount rate >= 0"
);
$discount
=
0
;
}
if
(
$discount
>
100
)
{
\Log
::
warning
(
"Expecting a discount rate <= 100"
);
$discount
=
100
;
}
$this
->
attributes
[
'discount'
]
=
$discount
;
}
/**
* List of wallets with this discount assigned.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public
function
wallets
()
{
return
$this
->
hasMany
(
'App
\W
allet'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Aug 25, 8:12 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
224822
Default Alt Text
Discount.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment