Changeset View
Changeset View
Standalone View
Standalone View
src/app/Discount.php
<?php | <?php | ||||
namespace App; | namespace App; | ||||
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 string $code | |||||
* @property string $description | |||||
* @property int $discount | |||||
* @property int $tenant_id | |||||
*/ | */ | ||||
class Discount extends Model | class Discount extends Model | ||||
{ | { | ||||
use HasTranslations; | use HasTranslations; | ||||
public $incrementing = false; | public $incrementing = false; | ||||
protected $keyType = 'string'; | protected $keyType = 'string'; | ||||
Show All 31 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'); | ||||
} | } | ||||
} | } |