add methods to detect distinct product type et article nature on shelve
This commit is contained in:
@@ -21,6 +21,11 @@ class ArticleNatures
|
||||
return $type ? self::getProductTypes()[$type] : false;
|
||||
}
|
||||
|
||||
public static function getProductTypeNameByClass($model)
|
||||
{
|
||||
return self::getProductTypeName(self::getProductTypeByModel($model));
|
||||
}
|
||||
|
||||
public static function getProductTypeName($type)
|
||||
{
|
||||
return self::getProductTypes()[$type] ?? false;
|
||||
@@ -30,16 +35,12 @@ class ArticleNatures
|
||||
{
|
||||
switch ($model) {
|
||||
case Specie::class:
|
||||
$type = 1;
|
||||
break;
|
||||
case Variety::class:
|
||||
$type = 1;
|
||||
break;
|
||||
return 1;
|
||||
case Merchandise::class:
|
||||
$type = 2;
|
||||
break;
|
||||
return 2;
|
||||
}
|
||||
return $type ?? false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getProductTypes()
|
||||
@@ -83,6 +84,12 @@ class ArticleNatures
|
||||
return ArticleNature::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getNamesByIds($ids)
|
||||
{
|
||||
$names = ArticleNature::byIds($ids)->pluck('name')->toArray();
|
||||
return array_map('strtolower', $names);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticleNature::find($id);
|
||||
|
||||
Reference in New Issue
Block a user