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;
|
||||
}
|
||||
|
||||
@@ -246,6 +246,12 @@ class Articles
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getArticleNaturesOptionsWithOffers($options = false)
|
||||
{
|
||||
$ids = self::getArticleNaturesIdsWithOffers($options);
|
||||
|
||||
}
|
||||
|
||||
public static function getArticleNaturesWithOffers($options = false)
|
||||
{
|
||||
return ArticleNatures::getNamesByIds(self::getArticleNaturesIdsWithOffers($options));
|
||||
|
||||
@@ -84,7 +84,7 @@ class Customers
|
||||
|
||||
public static function getWithAddresses($id = false)
|
||||
{
|
||||
return self::get($id, 'addresses');
|
||||
return self::get($id, ['invoicing_addresses', 'delivery_addresses']);
|
||||
}
|
||||
|
||||
public static function getName($id = false)
|
||||
@@ -99,6 +99,13 @@ class Customers
|
||||
return self::guard()->user();
|
||||
}
|
||||
|
||||
public static function get($id, $relations = false, $relationsCount = false)
|
||||
{
|
||||
$id = $id ? $id : self::getId();
|
||||
|
||||
return self::getModelRelations($relations, $relationsCount)->find($id);
|
||||
}
|
||||
|
||||
public static function getId()
|
||||
{
|
||||
return self::guard()->id();
|
||||
|
||||
@@ -15,13 +15,14 @@ class TagGroups
|
||||
|
||||
public static function getWithTagsAndCountOffers($category_id = false)
|
||||
{
|
||||
$data = [];
|
||||
$tags = Tag::withCountArticlesByCategory($category_id)->get()->toArray();
|
||||
$tag_groups = TagGroup::pluck('name', 'id')->toArray();
|
||||
foreach ($tags as $tag) {
|
||||
$data[$tag['tag_group_id']]['name'] = $tag_groups[$tag['tag_group_id']];
|
||||
if (! $tag['articles_count']) {
|
||||
continue;
|
||||
}
|
||||
$data[$tag['tag_group_id']]['name'] = $tag_groups[$tag['tag_group_id']];
|
||||
$data[$tag['tag_group_id']]['tags'][] = [
|
||||
'id' => $tag['id'],
|
||||
'name' => $tag['name'],
|
||||
|
||||
Reference in New Issue
Block a user