Changeset View
Changeset View
Standalone View
Standalone View
src/app/Discount.php
<?php | <?php | ||||
namespace App; | namespace App; | ||||
use App\Traits\BelongsToTenantTrait; | |||||
use App\Traits\UuidStrKeyTrait; | use App\Traits\UuidStrKeyTrait; | ||||
use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||
use Spatie\Translatable\HasTranslations; | use Spatie\Translatable\HasTranslations; | ||||
/** | /** | ||||
* The eloquent definition of a Discount. | * The eloquent definition of a Discount. | ||||
* | * | ||||
* @property bool $active | * @property bool $active | ||||
* @property string $code | * @property string $code | ||||
* @property string $description | * @property string $description | ||||
* @property int $discount | * @property int $discount | ||||
* @property int $tenant_id | * @property int $tenant_id | ||||
*/ | */ | ||||
class Discount extends Model | class Discount extends Model | ||||
{ | { | ||||
use BelongsToTenantTrait; | |||||
use HasTranslations; | use HasTranslations; | ||||
use UuidStrKeyTrait; | use UuidStrKeyTrait; | ||||
protected $casts = [ | protected $casts = [ | ||||
'discount' => 'integer', | 'discount' => 'integer', | ||||
]; | ]; | ||||
protected $fillable = [ | protected $fillable = [ | ||||
Show All 26 Lines | public function setDiscountAttribute($discount) | ||||
\Log::warning("Expecting a discount rate <= 100"); | \Log::warning("Expecting a discount rate <= 100"); | ||||
$discount = 100; | $discount = 100; | ||||
} | } | ||||
$this->attributes['discount'] = $discount; | $this->attributes['discount'] = $discount; | ||||
} | } | ||||
/** | /** | ||||
* The tenant for this discount. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function tenant() | |||||
{ | |||||
return $this->belongsTo('App\Tenant', 'tenant_id', 'id'); | |||||
} | |||||
/** | |||||
* List of wallets with this discount assigned. | * List of wallets with this discount assigned. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | * @return \Illuminate\Database\Eloquent\Relations\HasMany | ||||
*/ | */ | ||||
public function wallets() | public function wallets() | ||||
{ | { | ||||
return $this->hasMany('App\Wallet'); | return $this->hasMany('App\Wallet'); | ||||
} | } | ||||
} | } |