Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120823571
Discount.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
Discount.php
View Options
<?php
namespace
App
;
use
App\Traits\BelongsToTenantTrait
;
use
App\Traits\UuidStrKeyTrait
;
use
Illuminate\Database\Eloquent\Model
;
use
Spatie\Translatable\HasTranslations
;
/**
* The eloquent definition of a Discount.
*
* @property bool $active
* @property string $code
* @property string $description
* @property int $discount
* @property int $tenant_id
*/
class
Discount
extends
Model
{
use
BelongsToTenantTrait
;
use
HasTranslations
;
use
UuidStrKeyTrait
;
protected
$casts
=
[
'discount'
=>
'integer'
,
];
/** @var array<int, string> The attributes that are mass assignable */
protected
$fillable
=
[
'active'
,
'code'
,
'description'
,
'discount'
];
/** @var array<int, string> 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
(
Wallet
::
class
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:08 AM (4 d, 17 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ba/c4/e107ab83ce752a90980d047e179b
Default Alt Text
Discount.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline