change icons, css, add routing to merchandise, add mail templater, fixes

This commit is contained in:
Ludovic CANDELLIER
2023-02-12 23:34:48 +01:00
parent 8313e25f2e
commit f2f4788ce1
71 changed files with 1486 additions and 154 deletions

View File

@@ -3,6 +3,10 @@
namespace App\Repositories\Shop;
use App\Models\Shop\ArticleNature;
use App\Models\Shop\Article;
use App\Models\Botanic\Specie;
use App\Models\Botanic\Variety;
use App\Models\Shop\Merchandise;
class ArticleNatures
{
@@ -11,9 +15,36 @@ class ArticleNatures
return ArticleNature::get()->pluck('name', 'id')->toArray();
}
public static function getOptionsByMerchandise()
public static function getProductType($id)
{
return self::getOptionsByProductType(2);
$type = self::get($id)->product_type ?? false;
return $type ? self::getProductTypes()[$type] : false;
}
public static function getProductTypeName($type)
{
return self::getProductTypes()[$type] ?? false;
}
public static function getProductTypeByModel($model)
{
switch ($model) {
case Specie::class:
$type = 1;
break;
case Variety::class:
$type = 1;
break;
case Merchandise::class:
$type = 2;
break;
}
return $type ?? false;
}
public static function getProductTypes()
{
return ['', 'botanic', 'merchandise'];
}
public static function getOptionsByBotanic()
@@ -21,9 +52,30 @@ class ArticleNatures
return self::getOptionsByProductType(1);
}
public static function getOptionsByMerchandise()
{
return self::getOptionsByProductType(2);
}
public static function getOptionsByProductTypeModel($model)
{
$type = self::getProductTypeByModel($model);
return self::getOptionsByProductType($type);
}
public static function getOptionsByProductType($type)
{
return ArticleNature::byProductType($type)->get()->pluck('name', 'id')->toArray();
return self::getByProductType($type)->pluck('name', 'id')->toArray();
}
public static function getByProductType($type)
{
return ArticleNature::byProductType($type)->get();
}
public static function getByCategory($category_id)
{
return Article::byCategory($category_id)->select('article_nature_id')->distinct()->get();
}
public static function getAll()

View File

@@ -10,6 +10,7 @@ use App\Repositories\Core\Comments;
use App\Repositories\Botanic\Species;
use App\Repositories\Botanic\Varieties;
use App\Models\Shop\Article;
use App\Models\Shop\Merchandise;
use App\Traits\Repository\Imageable;
@@ -106,7 +107,7 @@ class Articles
$data['description'] = self::getFullDescriptionByArticle($article);
$images = self::getFullImagesByArticle($article);
$data['image'] = self::getPreviewSrc($images[0] ?? false);
$data['images'] = $images;
$data['images'] = count($images) ? $images : false;
$data['image_big'] = self::getImageSrc($images[0] ?? false);
$data['inherited'] = self::getInherited($id);
$data['categories'] = self::getCategoriesNameByArticle($article);
@@ -376,6 +377,22 @@ class Articles
return $article->categories->pluck('id')->toArray();
}
public static function getProductTypeByCategory($category_id)
{
$models = self::getProductTypesModelsByCategory($category_id);
return (($models[0] ?? false) == Merchandise::class) ? 'merchandise' : 'botanic';
}
public static function getProductTypesModelsByCategory($category_id)
{
return Article::byCategory($category_id)->select('product_type')->distinct()->get();
}
public static function countProductTypesByCategory($category_id)
{
return Article::byCategory($category_id)->select('product_type')->distinct()->count();
}
public static function getCategoriesNameByArticle($article)
{
return $article->categories->pluck('name', 'id')->toArray();

View File

@@ -4,6 +4,7 @@ namespace App\Repositories\Shop;
use Carbon\Carbon;
use App\Models\Shop\Order;
use Illuminate\Support\Str;
class Orders
{
@@ -70,6 +71,8 @@ class Orders
public static function create($data)
{
OrderStats::increase();
$data['uuid'] = Str::uuid()->toString();
$data['ref'] = self::getNewRef();
return Order::create($data);
}
@@ -111,4 +114,12 @@ class Orders
{
return ['', 'CARTE BANCAIRE', 'CHEQUE', 'VIREMENT BANCAIRE'];
}
public static function getNewRef()
{
$ref = date('ym') . '00000';
$last_ref = Order::orderBy('ref', 'desc')->where('ref', '>', $ref)->first();
return $last_ref ? $last_ref->ref + 1 : $ref + 1;
}
}