Move some product product\supplier and product\type::class methods into __get(), no functional changes

This commit is contained in:
2025-05-22 18:17:27 +10:00
parent 72b11172c8
commit 251aefa947
11 changed files with 46 additions and 77 deletions

View File

@@ -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 */
/**