fix devops error
This commit is contained in:
@@ -50,6 +50,7 @@ class Articles
|
||||
|
||||
public static function getSiblingsDescriptions($id)
|
||||
{
|
||||
$data = [];
|
||||
$siblings = self::getSiblings($id);
|
||||
foreach ($siblings as $sibling) {
|
||||
if ($sibling->description && ($sibling->article_nature->name ?? false)) {
|
||||
@@ -76,6 +77,7 @@ class Articles
|
||||
|
||||
public static function getOptionsWithNature()
|
||||
{
|
||||
$data = [];
|
||||
$articles = Article::with(['article_nature'])->get();
|
||||
foreach ($articles as $article) {
|
||||
$data[$article->id] = ($article->article_nature->name ?? null).' - '.$article->name;
|
||||
@@ -117,6 +119,7 @@ class Articles
|
||||
|
||||
public static function getFullDescriptionByArticle($article)
|
||||
{
|
||||
$data = [];
|
||||
switch ($article->product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$data['variety'] = $article->product->description;
|
||||
@@ -141,13 +144,6 @@ class Articles
|
||||
if ($siblings) {
|
||||
array_push($data, $siblings);
|
||||
}
|
||||
/*
|
||||
$data['resume'] = ($data['semences'] ?? null) .
|
||||
($data['plants'] ?? null) .
|
||||
($data['variety'] ?? null) .
|
||||
($data['merchandise'] ?? null) .
|
||||
($data['plus'] ?? null);
|
||||
*/
|
||||
$data['description'] = $article->description;
|
||||
|
||||
return $data;
|
||||
@@ -155,6 +151,7 @@ class Articles
|
||||
|
||||
public static function getArticlesByHomepage()
|
||||
{
|
||||
$data = [];
|
||||
$shelves = Categories::getByHomepage();
|
||||
foreach ($shelves as $shelve) {
|
||||
$data[] = [
|
||||
@@ -285,7 +282,7 @@ class Articles
|
||||
$article_nature_ids = $options['article_nature_ids'] ?? false;
|
||||
$product_type = $options['product_type'] ?? false;
|
||||
|
||||
$model = ($options['homepage'] ?? false) ? Article::homepage()->visible() : Article::visible();
|
||||
$model = $options['homepage'] ?? false ? Article::homepage()->visible() : Article::visible();
|
||||
$model = $category_id ? $model->byCategoryParent($category_id) : $model;
|
||||
$model = $tags ? $model->byTags($tags) : $model;
|
||||
$model = $search ? $model->search($search) : $model;
|
||||
@@ -307,7 +304,9 @@ class Articles
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
$data['article'] = self::getArticleEdit($id);
|
||||
$data = [
|
||||
'article' => self::getArticleEdit($id),
|
||||
];
|
||||
|
||||
return self::getMeta($data);
|
||||
}
|
||||
@@ -333,6 +332,7 @@ class Articles
|
||||
|
||||
public static function getInheritedByProduct($product_id, $product_type)
|
||||
{
|
||||
$data = [];
|
||||
switch ($product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$product = Varieties::get($product_id);
|
||||
@@ -414,7 +414,6 @@ class Articles
|
||||
|
||||
$data['categories_options'] = Categories::getOptions();
|
||||
$data['natures_options'] = ArticleNatures::getOptions();
|
||||
// $data['packages'] = ($data['article']['article_family_id'] ?? false) ? Packages::getSelectByFamily($data['article']['article_family_id']) : [];
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
$data['models_options'] = [
|
||||
'App\Models\Botanic\Specie' => 'Espèces',
|
||||
@@ -439,7 +438,7 @@ class Articles
|
||||
{
|
||||
$models = self::getProductTypesModelsByCategory($category_id);
|
||||
|
||||
return (($models[0] ?? false) == Merchandise::class) ? 'merchandise' : 'botanic';
|
||||
return ($models[0] ?? false) === Merchandise::class ? 'merchandise' : 'botanic';
|
||||
}
|
||||
|
||||
public static function getProductTypesModelsByCategory($category_id)
|
||||
@@ -549,6 +548,7 @@ class Articles
|
||||
$merchandise = $article->product ?? false;
|
||||
$images = count($merchandise->images ?? []) ? $merchandise->images : $images;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
return $images;
|
||||
@@ -575,6 +575,7 @@ class Articles
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$image = $article->product->image ?? false;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
return $image;
|
||||
@@ -591,9 +592,6 @@ class Articles
|
||||
$tags = $data['tags'] ?? false;
|
||||
unset($data['tags']);
|
||||
|
||||
$prices = $data['prices'] ?? false;
|
||||
unset($data['prices']);
|
||||
|
||||
$article = self::store($data);
|
||||
self::storeImages($article, $images);
|
||||
self::storeCategories($article, $categories);
|
||||
|
||||
@@ -9,7 +9,7 @@ class Baskets
|
||||
public static function addBasket($offerId, $quantity = 1, $update = false)
|
||||
{
|
||||
if (ShopCart::has($offerId) && ! $quantity) {
|
||||
$ret = ShopCart::remove($offerId);
|
||||
ShopCart::remove($offerId);
|
||||
}
|
||||
$data = $quantity ? self::getBasketData($offerId, $quantity) : false;
|
||||
|
||||
@@ -28,6 +28,7 @@ class Baskets
|
||||
$total = 0;
|
||||
$totalTaxed = 0;
|
||||
$totalWeight = 0;
|
||||
$detail = [];
|
||||
$basket = ShopCart::getContent();
|
||||
$offers = Offers::getWithVariationByIds(self::getIds());
|
||||
|
||||
@@ -42,7 +43,7 @@ class Baskets
|
||||
}
|
||||
$shipping = DeliveryTypeCalculations::getPriceByDeliveryType($deliveryTypeId, $totalWeight);
|
||||
|
||||
$data = [
|
||||
return [
|
||||
'detail' => $detail,
|
||||
'total' => $total,
|
||||
'taxes' => $totalTaxed - $total,
|
||||
@@ -54,8 +55,6 @@ class Baskets
|
||||
'weight' => $totalWeight,
|
||||
'sale_channel' => SaleChannels::getArray($saleChannelId),
|
||||
];
|
||||
|
||||
return $data ?? false;
|
||||
}
|
||||
|
||||
public static function getRowDetail($item, $offer, $prices, $weight)
|
||||
@@ -132,7 +131,6 @@ class Baskets
|
||||
public static function getArticleName(&$offer)
|
||||
{
|
||||
return $offer->article->name;
|
||||
// return $offer->article->name . ' (' . $offer->variation->name . ')';
|
||||
}
|
||||
|
||||
public static function getIds()
|
||||
|
||||
@@ -5,9 +5,12 @@ namespace App\Repositories\Shop;
|
||||
use App\Models\Shop\Category;
|
||||
use App\Repositories\Core\Categories as CategoryTrees;
|
||||
use App\Repositories\Core\Tag;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class Categories
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function getAncestorsByArticle($id)
|
||||
{
|
||||
$category = Articles::get($id)->categories()->first();
|
||||
@@ -31,16 +34,6 @@ class Categories
|
||||
return Category::hasAvailableOffers()->visible()->homepage()->orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Category::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id, $relations = false)
|
||||
{
|
||||
return $relations ? Category::with($relations)->findOrFail($id) : Category::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
$category = self::get($id, ['Parent']);
|
||||
@@ -72,11 +65,6 @@ class Categories
|
||||
return CategoryTrees::getTree();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Category::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$images = $data['images'] ?? false;
|
||||
@@ -92,13 +80,6 @@ class Categories
|
||||
return $category;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
|
||||
return $id ? self::update($data, $id) : self::create($data);
|
||||
}
|
||||
|
||||
public static function storeTags($category, $tags)
|
||||
{
|
||||
return Tag::storeTags($category, $tags);
|
||||
@@ -146,26 +127,7 @@ class Categories
|
||||
return CategoryTrees::moveTree($node_id, $target_id, $type);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Category::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? (int) $id : $data['id'];
|
||||
$category = self::get($id);
|
||||
$ret = $category->update($data);
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Category::destroy($id);
|
||||
}
|
||||
|
||||
public static function toggle_visible($id, $visible)
|
||||
public static function toggleVisible($id, $visible)
|
||||
{
|
||||
return self::update(['visible' => $visible], $id);
|
||||
}
|
||||
@@ -179,4 +141,9 @@ class Categories
|
||||
{
|
||||
return app('rinvex.categories.category')->find(1);
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return Category::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,16 +21,16 @@ class CustomerAddresses
|
||||
'zipcode' => $data['delivery_zipcode'],
|
||||
'city' => $data['delivery_city'],
|
||||
]);
|
||||
} else {
|
||||
return self::store([
|
||||
'customer_id' => $userId,
|
||||
'name' => $name,
|
||||
'address' => $data['address'],
|
||||
'address2' => $data['address2'],
|
||||
'zipcode' => $data['zipcode'],
|
||||
'city' => $data['city'],
|
||||
]);
|
||||
}
|
||||
|
||||
return self::store([
|
||||
'customer_id' => $userId,
|
||||
'name' => $name,
|
||||
'address' => $data['address'],
|
||||
'address2' => $data['address2'],
|
||||
'zipcode' => $data['zipcode'],
|
||||
'city' => $data['city'],
|
||||
]);
|
||||
}
|
||||
|
||||
public static function toggleActive($id, $active)
|
||||
|
||||
@@ -62,7 +62,6 @@ class Customers
|
||||
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
||||
'orders' => $datatableOrders->html(),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public static function getAvatar($id = false)
|
||||
@@ -160,14 +159,10 @@ class Customers
|
||||
|
||||
public static function storeFull($data)
|
||||
{
|
||||
// $invoices = $data['invoices'];
|
||||
$saleChannels = $data['sale_channels'];
|
||||
// unset($data['invoices']);
|
||||
unset($data['sale_channels']);
|
||||
$customer = self::store($data);
|
||||
if ($customer) {
|
||||
// self::storeAddresses($customer->id, $deliveries);
|
||||
// self::storeAddresses($customer->id, $invoices);
|
||||
self::storeSaleChannels($customer->id, $saleChannels);
|
||||
}
|
||||
|
||||
@@ -179,11 +174,9 @@ class Customers
|
||||
if (! $deliveries) {
|
||||
return false;
|
||||
}
|
||||
$deliveries = collect($deliveries)->transform(
|
||||
function ($item) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
$deliveries = collect($deliveries)->transform(function ($item) {
|
||||
return (int) $item;
|
||||
})->toArray();
|
||||
|
||||
return $customer->deliveries()->sync($deliveries);
|
||||
}
|
||||
|
||||
@@ -127,9 +127,8 @@ class Offers
|
||||
$tags = Categories::getTagsByCategory($category);
|
||||
$offers1 = self::getByCategory($category_id)->toArray();
|
||||
$offers2 = self::getByTags($tags)->toArray();
|
||||
$data = array_merge($offers1, $offers2);
|
||||
|
||||
return $data;
|
||||
return array_merge($offers1, $offers2);
|
||||
}
|
||||
|
||||
public static function getByCategory($category_id)
|
||||
|
||||
@@ -3,59 +3,25 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Price;
|
||||
use Yajra\DataTables\DataTables;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class Prices
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
$data['prices'] = Price::byArticle($id)->notGeneric()->get()->toArray();
|
||||
$data['generics'] = Price::byArticle($id)->generic()->with(['generic.prices', 'generic.category'])->get()->toArray();
|
||||
|
||||
return $data;
|
||||
return [
|
||||
'prices' => Price::byArticle($id)->notGeneric()->get()->toArray(),
|
||||
'generics' => Price::byArticle($id)->generic()->with([
|
||||
'generic.prices',
|
||||
'generic.category',
|
||||
])->get()->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
public static function getModel()
|
||||
{
|
||||
$model = Price::orderBy('name');
|
||||
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Price::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Price::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Price::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Price::destroy($id);
|
||||
return Price::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,12 @@ namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Tag;
|
||||
use App\Models\Shop\TagGroup;
|
||||
use App\Traits\Model\Basic;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class TagGroups
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return TagGroup::get()->SortBy('name')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
use Basic;
|
||||
|
||||
public static function getWithTagsAndCountOffers($category_id = false)
|
||||
{
|
||||
@@ -62,11 +60,6 @@ class TagGroups
|
||||
return $tags;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return TagGroup::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getSlug($id)
|
||||
{
|
||||
return self::get($id)->slug ?? '';
|
||||
@@ -77,18 +70,6 @@ class TagGroups
|
||||
return self::get($id)->name ?? '';
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return TagGroup::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$item = ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
$data['slug'] = Str::slug($data['name']);
|
||||
@@ -109,13 +90,13 @@ class TagGroups
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return TagGroup::destroy($id);
|
||||
}
|
||||
|
||||
public static function toggleVisible($id, $visible)
|
||||
{
|
||||
return self::update(['visible' => $visible], $id);
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return TagGroup::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class Tags
|
||||
|
||||
public static function getOptionsFullName()
|
||||
{
|
||||
$data = [];
|
||||
$tags = Tag::with('tag_group')->get()->toArray();
|
||||
foreach ($tags as $tag) {
|
||||
$data[$tag['id']] = $tag['tag_group']['name'].'-'.$tag['name'];
|
||||
@@ -61,7 +62,7 @@ class Tags
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$item = ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
$item = $data['id'] ?? false ? self::update($data) : self::create($data);
|
||||
|
||||
return $item->id;
|
||||
}
|
||||
@@ -71,9 +72,8 @@ class Tags
|
||||
$data['slug'] = self::buildSlug($data);
|
||||
$data['group'] = TagGroups::getName($data['tag_group_id']);
|
||||
$data['sort_order'] = self::getNewOrder($data['tag_group_id']);
|
||||
$tag = Tag::create($data);
|
||||
|
||||
return $tag;
|
||||
return Tag::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
|
||||
@@ -3,48 +3,19 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\TariffUnity;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class TariffUnities
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return TariffUnity::orderBy('id', 'asc')->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
public static function getModel()
|
||||
{
|
||||
return TariffUnity::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return TariffUnity::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return TariffUnity::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return TariffUnity::destroy($id);
|
||||
return TariffUnity::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Tax;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class Taxes
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Tax::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
@@ -16,35 +19,8 @@ class Taxes
|
||||
return Tax::orderBy('value', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
public static function getModel()
|
||||
{
|
||||
return Tax::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Tax::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Tax::destroy($id);
|
||||
return Tax::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Unity;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class Unities
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Unity::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
@@ -26,35 +29,8 @@ class Unities
|
||||
return self::get($id)->value ?? null;
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
public static function getModel()
|
||||
{
|
||||
return Unity::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Unity::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Unity::destroy($id);
|
||||
return Unity::query();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class Variations
|
||||
|
||||
public static function autocomplete($str)
|
||||
{
|
||||
$data = Variation::where('name', 'LIKE', "%${str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id');
|
||||
$data = Variation::where('name', 'LIKE', "%{$str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id');
|
||||
$export = [];
|
||||
foreach ($data as $key => $name) {
|
||||
$export[] = ['value' => $key, 'text' => $name];
|
||||
@@ -31,6 +31,7 @@ class Variations
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
$data = [];
|
||||
$variations = Variation::with(['package', 'unity'])->get();
|
||||
foreach ($variations as $variation) {
|
||||
$data[$variation->id] = self::getName($variation);
|
||||
|
||||
Reference in New Issue
Block a user