Page MenuHomePhorge

Discount.php
No OneTemporary

Discount.php

<?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',
];
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\Wallet');
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Sep 14, 1:29 PM (15 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
287342
Default Alt Text
Discount.php (1 KB)

Event Timeline