Fixes for deliveries vs sale_channels
This commit is contained in:
@@ -12,15 +12,11 @@ class Tag
|
||||
|
||||
public static function storeTags($model, $tags)
|
||||
{
|
||||
if ($tags) {
|
||||
$tags = collect($tags)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
return $model->syncTags($tags, true);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
$tags = $tags ? collect($tags)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray() : false;
|
||||
return $tags ? $model->syncTags($tags, true) : false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,8 +173,11 @@ class Articles
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$data['products'] = Species::getOptions();
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$data['products'] = Merchandises::getOptions();
|
||||
break;
|
||||
default:
|
||||
$data['products'] = Species::getOptions();
|
||||
$data['products'] = [];
|
||||
}
|
||||
|
||||
$data['categories_options'] = Categories::getOptions();
|
||||
@@ -184,6 +187,8 @@ class Articles
|
||||
$data['models_options'] = [
|
||||
'App\Models\Botanic\Specie' => 'Espèces',
|
||||
'App\Models\Botanic\Variety' => 'Variétés',
|
||||
'App\Models\Shop\Merchandise' => 'Marchandise',
|
||||
'App\Models\Shop\Merchandise' => 'Autres',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Category;
|
||||
use App\Repositories\Core\Tag;
|
||||
|
||||
class Categories
|
||||
{
|
||||
@@ -13,7 +14,25 @@ class Categories
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Category::with('CategoryTree')->find($id);
|
||||
return Category::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
$category = Category::with('CategoryTree')->find($id);
|
||||
$data = $category->toArray();
|
||||
$data['tags'] = self::getTagsByCategory($category);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getTagsByCategory($category)
|
||||
{
|
||||
return $category->tags->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
public static function getTagsNameByCategory($category)
|
||||
{
|
||||
return $category->tags->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getByCategory($category_id)
|
||||
@@ -28,7 +47,7 @@ class Categories
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Category::get()->pluck('name', 'category_id')->toArray();
|
||||
return Category::orderBy('name', 'asc')->pluck('name', 'category_id')->toArray();
|
||||
}
|
||||
|
||||
public static function storeFull($data)
|
||||
@@ -53,17 +72,7 @@ class Categories
|
||||
|
||||
public static function storeTags($category, $tags)
|
||||
{
|
||||
if ($tags) {
|
||||
$tags = collect($tags)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
|
||||
return $category->syncTags($tags, true);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return Tag::storeTags($category, $tags);
|
||||
}
|
||||
|
||||
public static function storeImages($category, $files)
|
||||
@@ -131,6 +140,11 @@ class Categories
|
||||
return Category::destroy($id);
|
||||
}
|
||||
|
||||
public static function toggle_visible($id, $visible)
|
||||
{
|
||||
return self::update(['visible' => $visible], $id);
|
||||
}
|
||||
|
||||
public static function getRoot()
|
||||
{
|
||||
return app('rinvex.categories.category')->find(1);
|
||||
|
||||
Reference in New Issue
Block a user