This commit is contained in:
ludo
2023-11-14 00:25:58 +01:00
parent 86b8156e38
commit 04df068931
3 changed files with 23 additions and 20 deletions

View File

@@ -27,11 +27,11 @@ class Articles
return $export;
}
public static function getOffersGroupedByNature($id, $sale_channel_id = false)
public static function getOffersGroupedByNature($id, $saleChannelId = false)
{
$article_ids = self::getSiblingsIds($id);
$article_ids[] = $id;
$offers = Offers::getOffersByArticles($article_ids, $sale_channel_id);
$articleIds = self::getSiblingsIds($id);
$articleIds[] = $id;
$offers = Offers::getOffersByArticles($articleIds, $saleChannelId);
foreach ($offers as $offer) {
$data[strtolower($offer->article_nature->name)][] = [
'id' => $offer->id,
@@ -90,10 +90,10 @@ class Articles
return Article::orderBy('name', 'asc')->get();
}
public static function getArticleToSell($id, $sale_channel_id = false)
public static function getArticleToSell($id, $saleChannelId = false)
{
$data = self::getArticle($id);
$data['offers'] = self::getOffersGroupedByNature($id, $sale_channel_id);
$data['offers'] = self::getOffersGroupedByNature($id, $saleChannelId);
return $data;
}
@@ -220,20 +220,20 @@ class Articles
public static function getArticlesWithOffers($options = false)
{
$sale_channel_id = $options['sale_channel_id'] ?? SaleChannels::getDefaultID();
$saleChannelId = $options['sale_channel_id'] ?? SaleChannels::getDefaultID();
$model = self::getModelByOptions($options);
$data = $model->withAvailableOffers($sale_channel_id)->with([
$data = $model->withAvailableOffers($saleChannelId)->with([
'image',
'product',
'article_nature',
'offers' => function ($query) use ($sale_channel_id) {
$query->bySaleChannel($sale_channel_id);
'offers' => function ($query) use ($saleChannelId) {
$query->bySaleChannel($saleChannelId);
},
'offers.tariff' => function ($query) use ($sale_channel_id) {
$query->bySaleChannel($sale_channel_id);
'offers.tariff' => function ($query) use ($saleChannelId) {
$query->bySaleChannel($saleChannelId);
},
'offers.tariff.price_lists' => function ($query) use ($sale_channel_id) {
$query->where('sale_channel_id', $sale_channel_id);
'offers.tariff.price_lists' => function ($query) use ($saleChannelId) {
$query->where('sale_channel_id', $saleChannelId);
},
'offers.tariff.price_lists.price_list_values',
'offers.variation.package',
@@ -255,9 +255,9 @@ class Articles
public static function getArticleNaturesIdsWithOffers($options = false)
{
$sale_channel_id = $options['sale_channel_id'] ?? SaleChannels::getDefaultID();
$saleChannelId = $options['sale_channel_id'] ?? SaleChannels::getDefaultID();
$model = self::getModelByOptions($options);
$data = $model->withAvailableOffers($sale_channel_id)->get()->pluck('article_nature_id')->unique();
$data = $model->withAvailableOffers($saleChannelId)->get()->pluck('article_nature_id')->unique();
return array_values($data->toArray());
}
@@ -276,9 +276,9 @@ class Articles
public static function getProductTypesClassesWithOffers($options = false)
{
$sale_channel_id = $options['sale_channel_id'] ?? SaleChannels::getDefaultID();
$saleChannelId = $options['sale_channel_id'] ?? SaleChannels::getDefaultID();
$model = self::getModelByOptions($options);
$data = $model->withAvailableOffers($sale_channel_id)->get()->pluck('product_type')->unique();
$data = $model->withAvailableOffers($saleChannelId)->get()->pluck('product_type')->unique();
return $data->toArray();
}

View File

@@ -92,6 +92,7 @@
@include('boilerplate::load.tinymce')
@push('js')
{!! JsValidator::formRequest('App\Http\Requests\Admin\Shop\StoreMerchandisePost', '#merchandise-form') !!}
<script>
$(function() {
initSelect2();

View File

@@ -1,4 +1,4 @@
{{ Form::open(['route' => 'Admin.Shop.Producers.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }}
{{ Form::open(['route' => 'Admin.Shop.Producers.store', 'id' => 'producer-form', 'autocomplete' => 'off', 'files' => true]) }}
<input type="hidden" name="id" id="id" value="{{ $producer['id'] ?? false }}">
<div class="row">
@@ -72,12 +72,14 @@
@include('boilerplate::load.tinymce')
@push('js')
{!! JsValidator::formRequest('App\Http\Requests\Admin\Shop\StoreProducerPost', '#producer-form') !!}
<script>
$(function() {
initSelect2();
initChevron();
initEditor();
initSaveForm();
initSaveForm('producer-form');
});
</script>
@endpush