Move some product product\supplier and product\type::class methods into __get(), no functional changes
This commit is contained in:
@@ -54,6 +54,7 @@ use App\Traits\ProviderRef;
|
||||
*
|
||||
* + setup_cost : Charge by supplier to setup this product
|
||||
*
|
||||
* + supplied : Suppliers product supplied
|
||||
* + supplier : Supplier for this offering
|
||||
*
|
||||
* Attributes for product types (type - Product/*)
|
||||
@@ -110,6 +111,9 @@ class Product extends Model
|
||||
|
||||
'setup_cost' => $this->supplied->setup_cost ?: 0,
|
||||
|
||||
'supplied' => $this->type->supplied,
|
||||
'supplier' => $this->supplied->supplier,
|
||||
|
||||
default => parent::__get($key),
|
||||
};
|
||||
}
|
||||
@@ -189,28 +193,6 @@ class Product extends Model
|
||||
return $this->morphTo(null,'model','model_id');
|
||||
}
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
/**
|
||||
* Suppliers product
|
||||
*
|
||||
* @return Model
|
||||
*/
|
||||
public function getSuppliedAttribute(): Model
|
||||
{
|
||||
return $this->type->supplied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suppliers of this product
|
||||
*
|
||||
* @return Model|null
|
||||
*/
|
||||
public function getSupplierAttribute(): ?Model
|
||||
{
|
||||
return $this->supplied->supplier;
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user