diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php index 5a2ebe7b..7410d705 100644 --- a/app/Repositories/Shop/Articles.php +++ b/app/Repositories/Shop/Articles.php @@ -38,6 +38,7 @@ class Articles public static function getMeta(&$data = []) { $data['categories_options'] = Categories::getOptions(); + $data['price_generics'] = PriceGenericCategories::getOptionsWithChildrens(); $data['families_options'] = ArticleFamilies::getOptions(); $data['taxes_options'] = Taxes::getOptions(); $data['attribute_families_options'] = PriceFamilies::getOptions(); @@ -64,7 +65,7 @@ class Articles public static function getPricesByArticle($article) { - return Prices::getByArticle($article->id)->toArray(); + return Prices::getByArticle($article->id); } public static function get($id) diff --git a/app/Repositories/Shop/PriceGenericCategories.php b/app/Repositories/Shop/PriceGenericCategories.php index 8a394ccd..5f23bf24 100644 --- a/app/Repositories/Shop/PriceGenericCategories.php +++ b/app/Repositories/Shop/PriceGenericCategories.php @@ -33,6 +33,21 @@ class PriceGenericCategories 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; diff --git a/app/Repositories/Shop/PriceGenerics.php b/app/Repositories/Shop/PriceGenerics.php index 5fd2ef3c..1d34cc47 100644 --- a/app/Repositories/Shop/PriceGenerics.php +++ b/app/Repositories/Shop/PriceGenerics.php @@ -29,6 +29,13 @@ class PriceGenerics 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(); diff --git a/app/Repositories/Shop/Prices.php b/app/Repositories/Shop/Prices.php index 3f82ca55..6f371ef3 100644 --- a/app/Repositories/Shop/Prices.php +++ b/app/Repositories/Shop/Prices.php @@ -16,8 +16,7 @@ class Prices public static function getByArticle($id) { - $prices = Article::byArticle($id)->with('prices.price')->get()->pluck('prices')->toArray()[0]; - // dump($prices); + $prices = Price::byArticle($id)->with('price')->get()->toArray(); $data = []; foreach ($prices as $price) { @@ -32,7 +31,7 @@ class Prices } } } - dump($data); + return $data; } public static function getDatatable() diff --git a/resources/views/Shop/Admin/Articles/partials/prices.blade.php b/resources/views/Shop/Admin/Articles/partials/prices.blade.php index 2f8a1e6f..2ba55d6c 100644 --- a/resources/views/Shop/Admin/Articles/partials/prices.blade.php +++ b/resources/views/Shop/Admin/Articles/partials/prices.blade.php @@ -72,7 +72,7 @@ function load_attribute_values($selector, family_id) { $.ajax({ - url : "{{ route('Shop.Admin.ArticleAttributeValues.getOptionsByFamily') }}", + url : "{{ route('Shop.Admin.PriceFamilyValues.getOptionsByFamily') }}", method : 'POST', data: { family_id: family_id }, success : function(data) { diff --git a/resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php b/resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php index 2abcf0f5..2c0d4389 100644 --- a/resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php +++ b/resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php @@ -7,35 +7,39 @@