Product class optimisation

This commit is contained in:
2023-05-04 10:02:25 +10:00
parent a5238bfbdc
commit 0ac35c3d43
10 changed files with 31 additions and 85 deletions

View File

@@ -96,7 +96,9 @@ class Product extends Model implements IDs
public function translate()
{
return $this->hasOne(ProductTranslate::class)
->where('language_id',(Auth::user() && Auth::user()->language_id) ? Auth::user()->language_id : config('site')->language_id);
->where('language_id',(Auth::user() && Auth::user()->language_id)
? Auth::user()->language_id
: config('site')->language_id);
}
/**
@@ -290,11 +292,12 @@ class Product extends Model implements IDs
/**
* Suppliers product
*
* @return Model|null
* @return Model
* @todo make internal as other values off this attribute are used, not the model itself
*/
public function getSuppliedAttribute(): ?Model
public function getSuppliedAttribute(): Model
{
return $this->type->supplied ? $this->type->supplied : NULL;
return $this->type->supplied;
}
/**