Add new version in repository
This commit is contained in:
@@ -12,7 +12,6 @@ use App\Models\Shop\ArticleComponent;
|
||||
|
||||
class ArticleComponents
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticleComponent::orderBy('name');
|
||||
@@ -21,7 +20,7 @@ class ArticleComponents
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticleComponent::orderBy('name','asc')->get();
|
||||
return ArticleComponent::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
@@ -32,7 +31,7 @@ class ArticleComponents
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
@@ -50,5 +49,4 @@ class ArticleComponents
|
||||
{
|
||||
return ArticleComponent::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,44 +2,35 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
use App\Models\Shop\ArticleNature;
|
||||
|
||||
use App\Models\Shop\ArticleFamily;
|
||||
|
||||
class ArticleFamilies
|
||||
class ArticleNatures
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticleFamily::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return ArticleFamily::get()->pluck('name','id')->toArray();
|
||||
return ArticleNature::get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticleFamily::orderBy('name','asc')->get();
|
||||
return ArticleNature::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticleFamily::find($id);
|
||||
return ArticleNature::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticleFamily::create($data);
|
||||
return ArticleNature::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
@@ -50,7 +41,6 @@ class ArticleFamilies
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticleFamily::destroy($id);
|
||||
return ArticleNature::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,87 +12,85 @@ use App\Models\Shop\ArticlePrice;
|
||||
|
||||
class ArticlePrices
|
||||
{
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
return ArticlePrice::byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
return ArticlePrice::byArticle($id)->get();
|
||||
}
|
||||
public static function getByArticleWithAttribute($id)
|
||||
{
|
||||
return ArticlePrice::with('article_attribute.attribute_value')->byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getByArticleWithAttribute($id)
|
||||
{
|
||||
return ArticlePrice::with('article_attribute.attribute_value')->byArticle($id)->get();
|
||||
}
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticlePrice::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticlePrice::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticlePrice::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticlePrice::orderBy('name','asc')->get();
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticlePrice::find($id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticlePrice::find($id);
|
||||
}
|
||||
public static function storePrices($article_id, $prices)
|
||||
{
|
||||
// dump($article_id);
|
||||
// dump($prices);
|
||||
// exit;
|
||||
if ($prices) {
|
||||
foreach ($prices as $key => $price) {
|
||||
$price['article_attribute']['article_attribute_value_id'] = $price['attribute']['attribute_value_id'];
|
||||
$prices[$key]['article_attribute_id'] = ArticleAttributes::storeAttribute($article_id, $price['article_attribute']);
|
||||
|
||||
public static function storePrices($article_id, $prices)
|
||||
{
|
||||
// dump($article_id);
|
||||
// dump($prices);
|
||||
// exit;
|
||||
if ($prices) {
|
||||
foreach ($prices as $key => $price) {
|
||||
$price['article_attribute']['article_attribute_value_id'] = $price['attribute']['attribute_value_id'];
|
||||
$prices[$key]['article_attribute_id'] = ArticleAttributes::storeAttribute($article_id, $price['article_attribute']);
|
||||
unset($prices[$key]['article_attribute']);
|
||||
unset($prices[$key]['attribute']);
|
||||
self::store($prices[$key]);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
unset($prices[$key]['article_attribute']);
|
||||
unset($prices[$key]['attribute']);
|
||||
self::store($prices[$key]);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static function store($data)
|
||||
{
|
||||
$attributes = isset($data['attributes']) ? $data['attributes'] : false;
|
||||
unset($data['attributes']);
|
||||
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$price = $id ? self::update($data) : self::create($data);
|
||||
|
||||
$ret = $attributes ? self::storeAttributes($price->id, $attributes) : false;
|
||||
|
||||
return $price->id;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$attributes = isset($data['attributes']) ? $data['attributes'] : false;
|
||||
unset($data['attributes']);
|
||||
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$price = $id ? self::update($data) : self::create($data);
|
||||
|
||||
$ret = $attributes ? self::storeAttributes($price->id, $attributes) : false;
|
||||
|
||||
return $price->id;
|
||||
}
|
||||
|
||||
public static function storeAttributes($article_price_id,$attributes)
|
||||
{
|
||||
return ArticleAttributes::storeAttribute($article_price_id, $attributes);
|
||||
}
|
||||
public static function storeAttributes($article_price_id, $attributes)
|
||||
{
|
||||
return ArticleAttributes::storeAttribute($article_price_id, $attributes);
|
||||
}
|
||||
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticlePrice::create($data);
|
||||
}
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticlePrice::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$article = ArticlePrice::find($id);
|
||||
$article->update($data);
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticlePrice::destroy($id);
|
||||
}
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$article = ArticlePrice::find($id);
|
||||
$article->update($data);
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticlePrice::destroy($id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,149 +12,178 @@ use App\Models\Shop\Article;
|
||||
|
||||
class Articles
|
||||
{
|
||||
public static function autocomplete($str)
|
||||
{
|
||||
$data = Article::where('name', 'LIKE', "%${str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id');
|
||||
$export = [];
|
||||
foreach ($data as $key => $name) {
|
||||
$export[] = ['value' => $key, 'text' => $name];
|
||||
}
|
||||
return $export;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Article::orderBy('name','asc')->get();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Article::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
$article = Article::with('product.tags')->findOrFail($id);
|
||||
$data['article'] = $article->toArray();
|
||||
$data['article']['categories'] = self::getCategoriesByArticle($article);
|
||||
$data['article']['tags'] = self::getTagsByArticle($article);
|
||||
$data['article']['prices'] = self::getPricesByArticle($article);
|
||||
self::getMeta($data);
|
||||
return $data;
|
||||
}
|
||||
public static function getFull($id)
|
||||
{
|
||||
$article = Article::with('product.tags')->findOrFail($id);
|
||||
$data['article'] = $article->toArray();
|
||||
$data['article']['inherited'] = self::getInherited($id);
|
||||
// dump($data);
|
||||
// exit;
|
||||
$data['article']['categories'] = self::getCategoriesByArticle($article);
|
||||
$data['article']['tags'] = self::getTagsByArticle($article);
|
||||
// $data['article']['prices'] = self::getPricesByArticle($article);
|
||||
self::getMeta($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getMeta(&$data = [])
|
||||
{
|
||||
$data['products'] = ( ($data['article']['product_type'] ?? false) == 'App\Models\Botanic\Variety') ? Varieties::getOptionsWithSpecie() : Species::getOptions();
|
||||
$data['categories_options'] = Categories::getOptions();
|
||||
$data['price_generics'] = PriceGenericCategories::getOptionsWithChildrens();
|
||||
$data['families_options'] = ArticleFamilies::getOptions();
|
||||
$data['taxes_options'] = Taxes::getOptions();
|
||||
$data['packages'] = ($data['article']['article_family_id'] ?? false) ? Packages::getSelectByFamily($data['article']['article_family_id']) : [];
|
||||
$data['unities'] = ($data['packages']['id'] ?? false) ? Unities::getSelectByPackage($data['packages']['id']) : [];
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
$data['models_options'] = ['App\Models\Botanic\Specie' => 'Espèces', 'App\Models\Botanic\Variety' => 'Variétés'];
|
||||
return $data;
|
||||
}
|
||||
public static function getInherited($id)
|
||||
{
|
||||
$article = Article::with('product.tags')->findOrFail($id);
|
||||
$product_type = $article->product_type;
|
||||
switch ($product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$data[] = ['name' => 'Espèces', 'description' => Species::getDescription($article->product->specie_id), 'tags' => Species::getTags($article->product->specie_id)];
|
||||
$data[] = ['name' => 'Variétés', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()];
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$data[] = ['name' => 'Espèces', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()];
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$data[] = ['name' => 'Marchandise', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()];
|
||||
break;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getByCategory($category_id)
|
||||
{
|
||||
return Article::with(['prices','product','image'])->get();
|
||||
}
|
||||
public static function getMeta(&$data = [])
|
||||
{
|
||||
$data['products'] = (($data['article']['product_type'] ?? false) == 'App\Models\Botanic\Variety') ? Varieties::getOptionsWithSpecie() : Species::getOptions();
|
||||
$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', 'App\Models\Botanic\Variety' => 'Variétés'];
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getCategoriesByArticle($article)
|
||||
{
|
||||
return $article->categories->pluck('id')->toArray();
|
||||
}
|
||||
public static function getByCategory($category_id)
|
||||
{
|
||||
return Article::byCategory($category_id)->with(['prices','product','image'])->get();
|
||||
}
|
||||
|
||||
public static function getTagsByArticle($article)
|
||||
{
|
||||
return $article->tags->pluck('id')->toArray();
|
||||
}
|
||||
public static function getCategoriesByArticle($article)
|
||||
{
|
||||
return $article->categories->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
public static function getPricesByArticle($article)
|
||||
{
|
||||
return Prices::getByArticle($article->id);
|
||||
}
|
||||
public static function getTagsByArticle($article)
|
||||
{
|
||||
return $article->tags->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Article::find($id);
|
||||
}
|
||||
public static function getPricesByArticle($article)
|
||||
{
|
||||
return Prices::getByArticle($article->id);
|
||||
}
|
||||
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$images = isset($data['images']) ? $data['images'] : false;
|
||||
$categories = isset($data['categories']) ? $data['categories'] : false;
|
||||
$tags = isset($data['tags']) ? $data['tags'] : false;
|
||||
$prices = isset($data['prices']) ? $data['prices'] : false;
|
||||
unset($data['images']);
|
||||
unset($data['categories']);
|
||||
unset($data['tags']);
|
||||
unset($data['prices']);
|
||||
$article = self::store($data);
|
||||
self::storeImages($article, $images);
|
||||
self::storeCategories($article, $categories);
|
||||
self::storeTags($article, $tags);
|
||||
self::storePrices($article, $prices);
|
||||
return $article->id;
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Article::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return $id ? self::update($data, $id) : self::create($data);
|
||||
}
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$images = isset($data['images']) ? $data['images'] : false;
|
||||
$categories = isset($data['categories']) ? $data['categories'] : false;
|
||||
$tags = isset($data['tags']) ? $data['tags'] : false;
|
||||
$prices = isset($data['prices']) ? $data['prices'] : false;
|
||||
unset($data['images']);
|
||||
unset($data['categories']);
|
||||
unset($data['tags']);
|
||||
unset($data['prices']);
|
||||
$article = self::store($data);
|
||||
self::storeImages($article, $images);
|
||||
self::storeCategories($article, $categories);
|
||||
self::storeTags($article, $tags);
|
||||
self::storePrices($article, $prices);
|
||||
return $article->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Article::create($data);
|
||||
}
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return $id ? self::update($data, $id) : self::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$article = self::get($id);
|
||||
$ret = $article->update($data);
|
||||
return $article;
|
||||
}
|
||||
public static function create($data)
|
||||
{
|
||||
return Article::create($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Article::destroy($id);
|
||||
}
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$article = self::get($id);
|
||||
$ret = $article->update($data);
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function storeCategories($article, $categories)
|
||||
{
|
||||
if ($categories) {
|
||||
$categories = collect($categories)->transform(function ($item, $key) {
|
||||
return (int) $item;
|
||||
})->toArray();
|
||||
return $article->syncCategories($categories, true);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Article::destroy($id);
|
||||
}
|
||||
|
||||
public static function storeTags($article, $tags)
|
||||
{
|
||||
return Tag::storeTags($article, $tags);
|
||||
}
|
||||
public static function storeCategories($article, $categories)
|
||||
{
|
||||
if ($categories) {
|
||||
$categories = collect($categories)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
return $article->syncCategories($categories, true);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function storePrices($article, $prices)
|
||||
{
|
||||
return ArticlePrices::storePrices($article->id, $prices);
|
||||
}
|
||||
public static function storeTags($article, $tags)
|
||||
{
|
||||
return Tag::storeTags($article, $tags);
|
||||
}
|
||||
|
||||
public static function storeImages($article, $files)
|
||||
{
|
||||
return Media::storeImages($article, $files);
|
||||
}
|
||||
public static function storePrices($article, $prices)
|
||||
{
|
||||
return ArticlePrices::storePrices($article->id, $prices);
|
||||
}
|
||||
|
||||
public static function storeImage($article, $file)
|
||||
{
|
||||
return Media::storeImage($article, $file);
|
||||
}
|
||||
public static function storeImages($article, $files)
|
||||
{
|
||||
return Media::storeImages($article, $files);
|
||||
}
|
||||
|
||||
public static function getImages($id)
|
||||
{
|
||||
return Media::getImages(self::get($id));
|
||||
}
|
||||
public static function storeImage($article, $file)
|
||||
{
|
||||
return Media::storeImage($article, $file);
|
||||
}
|
||||
|
||||
public static function getThumbSrc($image)
|
||||
{
|
||||
return Media::getThumbSrc($image);
|
||||
}
|
||||
public static function getImages($id)
|
||||
{
|
||||
return Media::getImages(self::get($id));
|
||||
}
|
||||
|
||||
public static function deleteImage($id, $index)
|
||||
{
|
||||
return Media::deleteImage(self::get($id), $index);
|
||||
}
|
||||
public static function getThumbSrc($image)
|
||||
{
|
||||
return Media::getThumbSrc($image);
|
||||
}
|
||||
|
||||
public static function deleteImage($id, $index)
|
||||
{
|
||||
return Media::deleteImage(self::get($id), $index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Models\Shop\Category;
|
||||
|
||||
class Categories
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Category::orderBy('name');
|
||||
@@ -17,7 +16,7 @@ class Categories
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Category::orderBy('name','asc')->get();
|
||||
return Category::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
@@ -32,15 +31,15 @@ class Categories
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Category::get()->pluck('name','category_id')->toArray();
|
||||
return Category::get()->pluck('name', 'category_id')->toArray();
|
||||
}
|
||||
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$images = isset($data['images']) ? $data['images'] : false;
|
||||
// $tags = isset($data['tags']) ? $data['tags'] : false;
|
||||
// $tags = isset($data['tags']) ? $data['tags'] : false;
|
||||
unset($data['images']);
|
||||
// unset($data['tags']);
|
||||
// unset($data['tags']);
|
||||
$category = self::store($data);
|
||||
self::storeImages($category, $images);
|
||||
// self::storeTags($category, $tags);
|
||||
@@ -50,23 +49,27 @@ class Categories
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return $id ? self::update($data, $id) : self::create($data);
|
||||
return $id ? self::update($data, $id) : self::create($data);
|
||||
}
|
||||
|
||||
public static function storeTags($category, $tags)
|
||||
{
|
||||
if ($tags) {
|
||||
$tags = collect($tags)->transform(function ($item, $key) {
|
||||
return (int) $item;
|
||||
})->toArray();
|
||||
$tags = collect($tags)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
return $category->syncTags($tags, true);
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function storeImages($category, $files)
|
||||
{
|
||||
if ($files) {
|
||||
foreach ($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
self::storeImage($category, $file);
|
||||
}
|
||||
}
|
||||
@@ -117,7 +120,7 @@ class Categories
|
||||
$id = $id ? $id : $data['id'];
|
||||
$category = Category::find($id);
|
||||
$ret = $category->update($data);
|
||||
CategoryTrees::update($data, $category->category_id);
|
||||
CategoryTrees::update($data, $category->category_id);
|
||||
return $category;
|
||||
}
|
||||
|
||||
@@ -132,5 +135,4 @@ class Categories
|
||||
{
|
||||
return app('rinvex.categories.category')->find(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ class CategoryTrees
|
||||
{
|
||||
public static function getTree()
|
||||
{
|
||||
$categories = app('rinvex.categories.category')->orderBy('_lft','asc')->get()->toTree()->toArray();
|
||||
$categories = app('rinvex.categories.category')->orderBy('_lft', 'asc')->get()->toTree()->toArray();
|
||||
return self::getChildren($categories[0]['children']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getChildren($data)
|
||||
{
|
||||
$tree = [];
|
||||
foreach ($data as $item)
|
||||
{
|
||||
foreach ($data as $item) {
|
||||
$leaf = [];
|
||||
$leaf['name'] = $item['name'];
|
||||
$leaf['id'] = $item['id'];
|
||||
@@ -35,14 +34,14 @@ class CategoryTrees
|
||||
$category_target = self::getNode($target_id);
|
||||
|
||||
switch ($type) {
|
||||
case 'after':
|
||||
dump("$node_id After $target_id");
|
||||
$category->afterNode($category_target);
|
||||
break;
|
||||
case 'inside':
|
||||
dump("$node_id inside $target_id");
|
||||
$category_target->appendNode($category);
|
||||
break;
|
||||
case 'after':
|
||||
dump("$node_id After $target_id");
|
||||
$category->afterNode($category_target);
|
||||
break;
|
||||
case 'inside':
|
||||
dump("$node_id inside $target_id");
|
||||
$category_target->appendNode($category);
|
||||
break;
|
||||
}
|
||||
$category->save();
|
||||
return "1";
|
||||
@@ -77,5 +76,4 @@ class CategoryTrees
|
||||
{
|
||||
return app('rinvex.categories.category')->find($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,48 +6,46 @@ use App\Models\Shop\Customer;
|
||||
|
||||
class Customers
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return Customer::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Customer::orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getOptionsByPackage($package_id)
|
||||
{
|
||||
return Customer::byPackage($package_id)->orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptionsByPackage($package_id)
|
||||
{
|
||||
return Customer::byPackage($package_id)->orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Customer::orderBy('value', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Customer::orderBy('value','asc')->get();
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Customer::find($id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Customer::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 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 Customer::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Customer::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return Customer::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Customer::destroy($id);
|
||||
}
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return Customer::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Customer::destroy($id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,48 +6,46 @@ use App\Models\Shop\Invoice;
|
||||
|
||||
class Invoices
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return Invoice::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Invoice::orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getOptionsByPackage($package_id)
|
||||
{
|
||||
return Invoice::byPackage($package_id)->orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptionsByPackage($package_id)
|
||||
{
|
||||
return Invoice::byPackage($package_id)->orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Invoice::orderBy('value', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Invoice::orderBy('value','asc')->get();
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Invoice::find($id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Invoice::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 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 Invoice::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Invoice::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return self::get($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Invoice::destroy($id);
|
||||
}
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return self::get($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Invoice::destroy($id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,48 +6,48 @@ use App\Models\Shop\Order;
|
||||
|
||||
class Orders
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return Order::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Order::orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getOptionsByPackage($package_id)
|
||||
{
|
||||
return Order::byPackage($package_id)->orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptionsByPackage($package_id)
|
||||
{
|
||||
return Order::byPackage($package_id)->orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Order::orderBy('value', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Order::orderBy('value','asc')->get();
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Order::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Order::findOrFail($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 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 Order::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Order::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return self::get($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Order::destroy($id);
|
||||
}
|
||||
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 Order::destroy($id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,62 +2,54 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\Package;
|
||||
|
||||
class Packages
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
public static function getOptions()
|
||||
{
|
||||
return Package::orderBy('value', 'asc')->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Package::orderBy('value','asc')->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Package::orderBy('value', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getSelectByFamily($family_id)
|
||||
{
|
||||
return Package::orderBy('value','asc')->byArticleFamily($family_id)->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getName($id)
|
||||
{
|
||||
return self::get($id)->value;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Package::orderBy('value','asc')->get();
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Package::find($id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Package::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 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 Package::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Package::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 update($data)
|
||||
{
|
||||
return Package::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Package::destroy($id);
|
||||
}
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Package::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\PriceGenericCategory;
|
||||
|
||||
class PriceGenericCategories
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = PriceGenericCategory::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return PriceGenericCategory::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return PriceGenericCategory::find($id);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return PriceGenericCategory::get()->pluck('name','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptionsWithChildrens()
|
||||
{
|
||||
$prices = PriceGenericCategory::with('price_generics')->get();
|
||||
$data = [];
|
||||
foreach ($prices as $key => $price)
|
||||
{
|
||||
$data[$key]['label'] = $price->name;
|
||||
foreach($price->price_generics as $generic)
|
||||
{
|
||||
$data[$key]['options'][$generic->id] = $generic->name;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$category = $id ? self::update($data) : self::create($data);
|
||||
return $category->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return PriceGenericCategory::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$category = PriceGenericCategory::find($id);
|
||||
$category->update($data);
|
||||
return $category;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return PriceGenericCategory::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\PriceGenericValue;
|
||||
|
||||
class PriceGenericValues
|
||||
{
|
||||
|
||||
public static function getByPriceGeneric($id)
|
||||
{
|
||||
return PriceGenericValue::byPriceGeneric($id)->get();
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = PriceGenericValue::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return PriceGenericValue::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return PriceGenericValue::find($id);
|
||||
}
|
||||
|
||||
public static function storePrices($generic_id, $values)
|
||||
{
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$value['price_generic_id'] = $generic_id;
|
||||
self::store($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$price = $id ? self::update($data) : self::create($data);
|
||||
return $price->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return PriceGenericValue::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$article = PriceGenericValue::find($id);
|
||||
$article->update($data);
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return PriceGenericValue::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\PriceGeneric;
|
||||
|
||||
class PriceGenerics
|
||||
{
|
||||
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
return PriceGeneric::byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getByArticleWithValues($id)
|
||||
{
|
||||
return PriceGeneric::with('values')->byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = PriceGeneric::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
$model = PriceGeneric::with('category')->get()->toArray();
|
||||
dump($model);
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return PriceGeneric::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return PriceGeneric::find($id);
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
return PriceGeneric::with(['category','prices'])->find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$prices = isset($data['prices']) ? $data['prices'] : false;
|
||||
unset($data['prices']);
|
||||
$generic = $id ? self::update($data) : self::create($data);
|
||||
PriceGenericValues::storePrices($generic->id, $prices);
|
||||
return $generic->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return PriceGeneric::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$generic = PriceGeneric::find($id);
|
||||
$generic->update($data);
|
||||
return $generic;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return PriceGeneric::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
67
app/Repositories/Shop/PriceListValues.php
Normal file
67
app/Repositories/Shop/PriceListValues.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\PriceListValue;
|
||||
|
||||
class PriceListValues
|
||||
{
|
||||
public static function getByPriceListValue($id)
|
||||
{
|
||||
return PriceListValue::byPriceListValue($id)->get();
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = PriceListValue::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return PriceListValue::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return PriceListValue::find($id);
|
||||
}
|
||||
|
||||
public static function storePrices($generic_id, $values)
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
$value['price_generic_id'] = $generic_id;
|
||||
self::store($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$price = $id ? self::update($data) : self::create($data);
|
||||
return $price->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return PriceListValue::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 PriceListValue::destroy($id);
|
||||
}
|
||||
}
|
||||
70
app/Repositories/Shop/PriceLists.php
Normal file
70
app/Repositories/Shop/PriceLists.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\Shop\PriceList;
|
||||
|
||||
class PriceLists
|
||||
{
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
return PriceList::byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getByArticleWithValues($id)
|
||||
{
|
||||
return PriceList::with('values')->byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return PriceList::with('prices')->get()->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return PriceList::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return PriceList::find($id);
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
return PriceList::with(['price_list_values'])->find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = $data['id'] ?? false;
|
||||
$price_list_values = $data['price_list_values'] ?? false;
|
||||
unset($data['price_list_values']);
|
||||
$price_list = $id ? self::update($data) : self::create($data);
|
||||
PriceListValues::storePrices($price_list->id, $price_list_values);
|
||||
return $price_list;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return PriceList::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 PriceList::destroy($id);
|
||||
}
|
||||
}
|
||||
@@ -13,50 +13,51 @@ use App\Models\Shop\Price;
|
||||
|
||||
class Prices
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Price::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Price::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Price::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Price::orderBy('name','asc')->get();
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Price::find($id);
|
||||
}
|
||||
|
||||
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 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 create($data)
|
||||
{
|
||||
return Price::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Price::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Price::destroy($id);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
48
app/Repositories/Shop/SaleChannels.php
Normal file
48
app/Repositories/Shop/SaleChannels.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\SaleChannel;
|
||||
|
||||
class SaleChannels
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return SaleChannel::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return SaleChannel::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return SaleChannel::findOrFail($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 SaleChannel::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 SaleChannel::destroy($id);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ use App\Models\Shop\TagGroup;
|
||||
|
||||
class TagGroups
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = TagGroup::query();
|
||||
@@ -17,8 +16,8 @@ class TagGroups
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return TagGroup::get()->SortBy('name')->pluck('name','id')->toArray();
|
||||
}
|
||||
return TagGroup::get()->SortBy('name')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getTreeTags()
|
||||
{
|
||||
@@ -39,7 +38,7 @@ class TagGroups
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return TagGroup::orderBy('name','asc')->get();
|
||||
return TagGroup::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
@@ -50,7 +49,7 @@ class TagGroups
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
@@ -68,5 +67,4 @@ class TagGroups
|
||||
{
|
||||
return TagGroup::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ use App\Models\Shop\Tag;
|
||||
|
||||
class Tags
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Tag::orderBy('name');
|
||||
@@ -21,12 +20,12 @@ class Tags
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Tag::get()->pluck('name','id')->toArray();
|
||||
}
|
||||
return Tag::get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Tag::orderBy('order','asc')->get();
|
||||
return Tag::orderBy('order', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
@@ -37,7 +36,7 @@ class Tags
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
|
||||
48
app/Repositories/Shop/TariffUnities.php
Normal file
48
app/Repositories/Shop/TariffUnities.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\TariffUnity;
|
||||
|
||||
class TariffUnities
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return TariffUnity::orderBy('id', 'asc')->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
63
app/Repositories/Shop/Tariffs.php
Normal file
63
app/Repositories/Shop/Tariffs.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Tariff;
|
||||
|
||||
class Tariffs
|
||||
{
|
||||
public static function autocomplete($str)
|
||||
{
|
||||
$data = Tariff::where('name', 'LIKE', "%${str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id');
|
||||
$export = [];
|
||||
foreach ($data as $key => $name) {
|
||||
$export[] = ['value' => $key, 'text' => $name];
|
||||
}
|
||||
return $export;
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Tariff::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getStatuses()
|
||||
{
|
||||
return ['Actif','Suspendu','Invisible','Obsolete'];
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Tariff::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Tariff::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 Tariff::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 Tariff::destroy($id);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ use App\Models\Shop\Tax;
|
||||
|
||||
class Taxes
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
return Datatables::of($model)->make(true);
|
||||
@@ -20,12 +19,12 @@ class Taxes
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Tax::orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
return Tax::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Tax::orderBy('value','asc')->get();
|
||||
return Tax::orderBy('value', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
@@ -36,7 +35,7 @@ class Taxes
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
@@ -45,14 +44,16 @@ class Taxes
|
||||
return Tax::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
return Tax::find($id)->update($data);
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Tax::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,48 +6,53 @@ use App\Models\Shop\Unity;
|
||||
|
||||
class Unities
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return Unity::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Unity::orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getOptionsByPackage($package_id)
|
||||
{
|
||||
return Unity::byPackage($package_id)->orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptionsByPackage($package_id)
|
||||
{
|
||||
return Unity::byPackage($package_id)->orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Unity::orderBy('value', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Unity::orderBy('value','asc')->get();
|
||||
}
|
||||
public static function getName($id)
|
||||
{
|
||||
return self::get($id)->value;
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Unity::find($id);
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
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 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 create($data)
|
||||
{
|
||||
return Unity::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return Unity::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Unity::destroy($id);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
85
app/Repositories/Shop/Variations.php
Normal file
85
app/Repositories/Shop/Variations.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Variation;
|
||||
|
||||
class Variations
|
||||
{
|
||||
public static function autocomplete($str)
|
||||
{
|
||||
$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];
|
||||
}
|
||||
return $export;
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
$variations = Variation::with(['package','unity'])->get();
|
||||
foreach ($variations as $variation) {
|
||||
$data[$variation->id] = self::getName($variation);
|
||||
}
|
||||
natsort($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getNameByID($id)
|
||||
{
|
||||
return self::getName(sef::getFull($id));
|
||||
}
|
||||
|
||||
public static function getName($variation)
|
||||
{
|
||||
return $variation->package->value . ' ' . $variation->quantity . ' ' . $variation->unity->value;
|
||||
}
|
||||
|
||||
public static function buildName($data)
|
||||
{
|
||||
return Packages::getName($data['package_id']) . ' ' . $data['quantity'] . ' ' . Unities::getName($data['unity_id']);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Variation::orderBy('value', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
return Variation::with(['package','unity'])->findOrFail($id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Variation::findOrFail($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)
|
||||
{
|
||||
$data['name'] = self::buildName($data);
|
||||
return Variation::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$variation = self::get($id);
|
||||
$data['name'] = self::buildName($data);
|
||||
$variation->update($data);
|
||||
return $variation;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Variation::destroy($id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user