Changeset View
Changeset View
Standalone View
Standalone View
src/app/Package.php
<?php | <?php | ||||
namespace App; | namespace App; | ||||
use App\Traits\BelongsToTenantTrait; | |||||
use App\Traits\UuidStrKeyTrait; | use App\Traits\UuidStrKeyTrait; | ||||
use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||
use Spatie\Translatable\HasTranslations; | use Spatie\Translatable\HasTranslations; | ||||
/** | /** | ||||
* The eloquent definition of a Package. | * The eloquent definition of a Package. | ||||
* | * | ||||
* A package is a set of SKUs that a user can select, so that instead of; | * A package is a set of SKUs that a user can select, so that instead of; | ||||
Show All 14 Lines | |||||
* @property int $discount_rate | * @property int $discount_rate | ||||
* @property string $id | * @property string $id | ||||
* @property string $name | * @property string $name | ||||
* @property ?int $tenant_id | * @property ?int $tenant_id | ||||
* @property string $title | * @property string $title | ||||
*/ | */ | ||||
class Package extends Model | class Package extends Model | ||||
{ | { | ||||
use BelongsToTenantTrait; | |||||
use HasTranslations; | use HasTranslations; | ||||
use UuidStrKeyTrait; | use UuidStrKeyTrait; | ||||
public $timestamps = false; | public $timestamps = false; | ||||
protected $fillable = [ | protected $fillable = [ | ||||
'description', | 'description', | ||||
'discount_rate', | 'discount_rate', | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | class Package extends Model | ||||
{ | { | ||||
return $this->belongsToMany( | return $this->belongsToMany( | ||||
'App\Sku', | 'App\Sku', | ||||
'package_skus' | 'package_skus' | ||||
)->using('App\PackageSku')->withPivot( | )->using('App\PackageSku')->withPivot( | ||||
['qty'] | ['qty'] | ||||
); | ); | ||||
} | } | ||||
/** | |||||
* The tenant for this package. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function tenant() | |||||
{ | |||||
return $this->belongsTo('App\Tenant', 'tenant_id', 'id'); | |||||
} | |||||
} | } |