Changeset View
Changeset View
Standalone View
Standalone View
src/app/Plan.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 Plan. | * The eloquent definition of a Plan. | ||||
* | * | ||||
* A Plan is a grouping of packages, such as a "Family Plan". | * A Plan is a grouping of packages, such as a "Family Plan". | ||||
* | * | ||||
* A "Family Plan" as such may exist of "2 or more Kolab packages", | * A "Family Plan" as such may exist of "2 or more Kolab packages", | ||||
* and apply a discount for the third and further Kolab packages. | * and apply a discount for the third and further Kolab packages. | ||||
* | * | ||||
* @property string $description | |||||
* @property int $discount_qty | |||||
* @property int $discount_rate | |||||
* @property string $id | |||||
* @property string $name | |||||
* @property \App\Package[] $packages | * @property \App\Package[] $packages | ||||
* @property datetime $promo_from | |||||
* @property datetime $promo_to | |||||
* @property ?int $tenant_id | |||||
* @property string $title | |||||
*/ | */ | ||||
class Plan extends Model | class Plan extends Model | ||||
{ | { | ||||
use HasTranslations; | use HasTranslations; | ||||
public $incrementing = false; | public $incrementing = false; | ||||
protected $keyType = 'string'; | protected $keyType = 'string'; | ||||
public $timestamps = false; | public $timestamps = false; | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | public function hasDomain(): bool | ||||
foreach ($this->packages as $package) { | foreach ($this->packages as $package) { | ||||
if ($package->isDomain()) { | if ($package->isDomain()) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | |||||
* The tenant for this plan. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function tenant() | |||||
{ | |||||
return $this->belongsTo('App\Tenant', 'tenant_id', 'id'); | |||||
} | |||||
} | } |