fix on customer auth, fix filters on shelves, refactor for article_nature, add slug
This commit is contained in:
@@ -26,44 +26,21 @@ class ArticleNatures
|
||||
|
||||
public static function getIdBySlug($slug)
|
||||
{
|
||||
switch ($slug) {
|
||||
case 'semences':
|
||||
$id = 1;
|
||||
break;
|
||||
case 'plants':
|
||||
$id = 2;
|
||||
break;
|
||||
case 'legumes':
|
||||
$id = 3;
|
||||
break;
|
||||
case 'marchandises':
|
||||
$id = 4;
|
||||
break;
|
||||
default:
|
||||
$id = 1;
|
||||
break;
|
||||
}
|
||||
$model = self::getBySlug($slug);
|
||||
|
||||
return $model ? $model->id : false;
|
||||
}
|
||||
|
||||
return $id;
|
||||
public static function getBySlug($slug)
|
||||
{
|
||||
return ArticleNature::bySlug($slug)->first();
|
||||
}
|
||||
|
||||
public static function getProductTypeBySlug($slug)
|
||||
{
|
||||
switch ($slug) {
|
||||
case 'semences':
|
||||
case 'plants':
|
||||
case 'legumes':
|
||||
$productType = 'botanic';
|
||||
break;
|
||||
case 'marchandises':
|
||||
$productType = 'merchandise';
|
||||
break;
|
||||
default:
|
||||
$productType = 'botanic';
|
||||
break;
|
||||
}
|
||||
$id = self::getIdBySlug($slug);
|
||||
|
||||
return $productType;
|
||||
return $id ? self::getProductType($id) : false;
|
||||
}
|
||||
|
||||
public static function storeIcon($nature, $file, $collection = 'images')
|
||||
@@ -75,7 +52,8 @@ class ArticleNatures
|
||||
|
||||
public static function getProductType($id)
|
||||
{
|
||||
$type = self::get($id)->product_type ?? false;
|
||||
$model = self::get($id);
|
||||
$type = $model ? $model->product_type : false;
|
||||
|
||||
return $type ? self::getProductTypes()[$type] : false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user