Changeset View
Changeset View
Standalone View
Standalone View
src/app/Sku.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 Stock Keeping Unit (SKU). | * The eloquent definition of a Stock Keeping Unit (SKU). | ||||
* | |||||
* @property bool $active | |||||
* @property int $cost | |||||
* @property string $description | |||||
* @property int $fee The fee that the tenant pays to us | |||||
* @property string $handler_class | |||||
* @property string $id | |||||
* @property string $name | |||||
* @property string $period | |||||
* @property ?int $tenant_id | |||||
* @property string $title | |||||
* @property int $units_free | |||||
*/ | */ | ||||
class Sku extends Model | class Sku extends Model | ||||
{ | { | ||||
use HasTranslations; | use HasTranslations; | ||||
public $incrementing = false; | public $incrementing = false; | ||||
protected $keyType = 'string'; | protected $keyType = 'string'; | ||||
protected $casts = [ | protected $casts = [ | ||||
'units_free' => 'integer' | 'units_free' => 'integer' | ||||
]; | ]; | ||||
protected $fillable = [ | protected $fillable = [ | ||||
'active', | 'active', | ||||
'cost', | 'cost', | ||||
'description', | 'description', | ||||
'fee', | |||||
'handler_class', | 'handler_class', | ||||
'name', | 'name', | ||||
// persist for annual domain registration | // persist for annual domain registration | ||||
'period', | 'period', | ||||
'title', | 'title', | ||||
'units_free', | 'units_free', | ||||
]; | ]; | ||||
Show All 20 Lines | class Sku extends Model | ||||
*/ | */ | ||||
public function packages() | public function packages() | ||||
{ | { | ||||
return $this->belongsToMany( | return $this->belongsToMany( | ||||
'App\Package', | 'App\Package', | ||||
'package_skus' | 'package_skus' | ||||
)->using('App\PackageSku')->withPivot(['cost', 'qty']); | )->using('App\PackageSku')->withPivot(['cost', 'qty']); | ||||
} | } | ||||
/** | |||||
* The tenant for this SKU. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function tenant() | |||||
{ | |||||
return $this->belongsTo('App\Tenant', 'tenant_id', 'id'); | |||||
} | |||||
} | } |