Changeset View
Changeset View
Standalone View
Standalone View
src/app/Plan.php
Show All 28 Lines | |||||
class Plan extends Model | class Plan extends Model | ||||
{ | { | ||||
use BelongsToTenantTrait; | use BelongsToTenantTrait; | ||||
use HasTranslations; | use HasTranslations; | ||||
use UuidStrKeyTrait; | use UuidStrKeyTrait; | ||||
public $timestamps = false; | public $timestamps = false; | ||||
/** @var array<int, string> The attributes that are mass assignable */ | |||||
protected $fillable = [ | protected $fillable = [ | ||||
'title', | 'title', | ||||
'name', | 'name', | ||||
'description', | 'description', | ||||
// a start and end datetime for this promotion | // a start and end datetime for this promotion | ||||
'promo_from', | 'promo_from', | ||||
'promo_to', | 'promo_to', | ||||
// discounts start at this quantity | // discounts start at this quantity | ||||
'discount_qty', | 'discount_qty', | ||||
// the rate of the discount for this plan | // the rate of the discount for this plan | ||||
'discount_rate', | 'discount_rate', | ||||
]; | ]; | ||||
/** @var array<string, string> The attributes that should be cast */ | |||||
protected $casts = [ | protected $casts = [ | ||||
'promo_from' => 'datetime', | 'promo_from' => 'datetime:Y-m-d H:i:s', | ||||
'promo_to' => 'datetime', | 'promo_to' => 'datetime:Y-m-d H:i:s', | ||||
'discount_qty' => 'integer', | 'discount_qty' => 'integer', | ||||
'discount_rate' => 'integer' | 'discount_rate' => 'integer' | ||||
]; | ]; | ||||
/** @var array Translatable properties */ | /** @var array<int, string> Translatable properties */ | ||||
public $translatable = [ | public $translatable = [ | ||||
'name', | 'name', | ||||
'description', | 'description', | ||||
]; | ]; | ||||
/** | /** | ||||
* The list price for this package at the minimum configuration. | * The list price for this package at the minimum configuration. | ||||
* | * | ||||
Show All 16 Lines | class Plan extends Model | ||||
* The plan contains one or more packages. Each package may have its minimum number (for | * The plan contains one or more packages. Each package may have its minimum number (for | ||||
* billing) or its maximum (to allow topping out "enterprise" customers on a "small business" | * billing) or its maximum (to allow topping out "enterprise" customers on a "small business" | ||||
* plan). | * plan). | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany | ||||
*/ | */ | ||||
public function packages() | public function packages() | ||||
{ | { | ||||
return $this->belongsToMany( | return $this->belongsToMany(Package::class, 'plan_packages') | ||||
'App\Package', | ->using(PlanPackage::class) | ||||
'plan_packages' | ->withPivot([ | ||||
)->using('App\PlanPackage')->withPivot( | |||||
[ | |||||
'qty', | 'qty', | ||||
'qty_min', | 'qty_min', | ||||
'qty_max', | 'qty_max', | ||||
'discount_qty', | 'discount_qty', | ||||
'discount_rate' | 'discount_rate' | ||||
] | ]); | ||||
); | |||||
} | } | ||||
/** | /** | ||||
* Checks if the plan has any type of domain SKU assigned. | * Checks if the plan has any type of domain SKU assigned. | ||||
* | * | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
public function hasDomain(): bool | public function hasDomain(): bool | ||||
Show All 10 Lines |