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; | ||||
use App\Traits\BelongsToTenantTrait; | |||||
use App\Traits\UuidKeyTrait; | use App\Traits\UuidKeyTrait; | ||||
/** | /** | ||||
* The eloquent definition of a Stock Keeping Unit (SKU). | * The eloquent definition of a Stock Keeping Unit (SKU). | ||||
* | * | ||||
* @property bool $active | * @property bool $active | ||||
* @property int $cost | * @property int $cost | ||||
* @property string $description | * @property string $description | ||||
* @property int $fee The fee that the tenant pays to us | * @property int $fee The fee that the tenant pays to us | ||||
* @property string $handler_class | * @property string $handler_class | ||||
* @property string $id | * @property string $id | ||||
* @property string $name | * @property string $name | ||||
* @property string $period | * @property string $period | ||||
* @property ?int $tenant_id | * @property ?int $tenant_id | ||||
* @property string $title | * @property string $title | ||||
* @property int $units_free | * @property int $units_free | ||||
*/ | */ | ||||
class Sku extends Model | class Sku extends Model | ||||
{ | { | ||||
use BelongsToTenantTrait; | |||||
use HasTranslations; | use HasTranslations; | ||||
use UuidKeyTrait; | use UuidKeyTrait; | ||||
protected $casts = [ | protected $casts = [ | ||||
'units_free' => 'integer' | 'units_free' => 'integer' | ||||
]; | ]; | ||||
protected $fillable = [ | protected $fillable = [ | ||||
Show All 32 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'); | |||||
} | |||||
} | } |