Changeset View
Changeset View
Standalone View
Standalone View
src/app/PlanPackage.php
Show All 9 Lines | |||||
* @property int $discount_qty | * @property int $discount_qty | ||||
* @property int $discount_rate | * @property int $discount_rate | ||||
* @property string $plan_id | * @property string $plan_id | ||||
* @property string $package_id | * @property string $package_id | ||||
* @property int $qty | * @property int $qty | ||||
* @property int $qty_max | * @property int $qty_max | ||||
* @property int $qty_min | * @property int $qty_min | ||||
* @property \App\Package $package | * @property \App\Package $package | ||||
* @property \App\Plan $plan | |||||
*/ | */ | ||||
class PlanPackage extends Pivot | class PlanPackage extends Pivot | ||||
{ | { | ||||
protected $fillable = [ | protected $fillable = [ | ||||
'plan_id', | 'plan_id', | ||||
'package_id', | 'package_id', | ||||
'qty', | 'qty', | ||||
'qty_max', | 'qty_max', | ||||
Show All 23 Lines | public function cost() | ||||
$costs += $this->package->cost() * $this->qty_min; | $costs += $this->package->cost() * $this->qty_min; | ||||
} elseif ($this->qty > 0) { | } elseif ($this->qty > 0) { | ||||
$costs += $this->package->cost() * $this->qty; | $costs += $this->package->cost() * $this->qty; | ||||
} | } | ||||
return $costs; | return $costs; | ||||
} | } | ||||
/** | |||||
* The package in this relation. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function package() | public function package() | ||||
{ | { | ||||
return $this->belongsTo('App\Package'); | return $this->belongsTo('App\Package'); | ||||
} | } | ||||
/** | |||||
* The plan in this relation. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function plan() | |||||
{ | |||||
return $this->belongsTo('App\Plan'); | |||||
} | |||||
} | } |