Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117750940
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
Illuminate\Database\Eloquent\Relations\HasMany
;
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 list<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 HasMany<Wallet, $this>
*/
public
function
wallets
()
{
return
$this
->
hasMany
(
Wallet
::
class
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Apr 4, 2:44 AM (4 d, 15 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
84/2c/211559b877ebcffd4185cee0850f
Default Alt Text
Discount.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline