Skip to content
Snippets Groups Projects
Commit 2b5bdd67 authored by suvorova-ma's avatar suvorova-ma
Browse files

Merge branch 'DCTN-494/fix' into 'master'

fix: showing of the lense

See merge request !6
parents 0d76bcdc 2108d018
No related branches found
No related tags found
1 merge request!6fix: showing of the lense
...@@ -22,18 +22,16 @@ public static function query(LensRequest $request, $query) ...@@ -22,18 +22,16 @@ public static function query(LensRequest $request, $query)
if ($data) { if ($data) {
$existFields = Product::where('retailer_id', $data['retailer'])->pluck('sku')->all(); $existFields = Product::where('retailer_id', $data['retailer'])->pluck('sku')->all();
$returnQuery = $query $returnQuery = $query
->where('retailer_id', '!=', $data['retailer']) ->where('retailer_id', '!=', $data['retailer'])
->whereIn('sku', $existFields) ->whereIn('sku', $existFields)
->join('retailers as r', 'products.retailer_id', '=', 'r.id'); ->join('retailers as r', 'products.retailer_id', '=', 'r.id');
if($data['field'] === 'name') if ($data['field'] === 'name') {
{
$returnQuery->select( $returnQuery->select(
'sku', 'sku',
DB::raw('group_concat(products.id) as id'), DB::raw('group_concat(products.id) as id'),
DB::raw('group_concat(products.name) as name'), DB::raw('group_concat(products.name) as name'),
DB::raw('group_concat(r.id) as retailer_id')); DB::raw('group_concat(r.id) as retailer_id'));
} } else {
else{
$returnQuery->select( $returnQuery->select(
'sku', 'sku',
DB::raw('group_concat(products.id) as id'), DB::raw('group_concat(products.id) as id'),
...@@ -76,16 +74,19 @@ public function fields(NovaRequest $request) ...@@ -76,16 +74,19 @@ public function fields(NovaRequest $request)
$availeble = Product::where('retailer_id', $key)->whereIn('sku', $existFields)->get(); $availeble = Product::where('retailer_id', $key)->whereIn('sku', $existFields)->get();
if (count($availeble) !== 0) { if (count($availeble) !== 0) {
array_push($fields, array_push($fields,
Text::make($retailer . ' ' . $data['field'], function () use ($count, $data) { Text::make($retailer . ' ' . $data['field'], function () use ($count, $data, $key) {
$field = $data['field']; $fields = explode(',', $this[$data['field']]);
$fields = explode(',', $this[$field]); if (!array_key_exists($count, $fields)) {
if (count($fields) < $count + 1) { $count = 0;
return null; }
$currentProduct = Product::where('retailer_id', $key)->where('sku', $this->sku)->get();
if (count($currentProduct) !== 0) {
return $fields[$count];
} }
return $fields[$count]; return null;
})); }));
$count++;
} }
$count++;
} }
return $fields; return $fields;
} }
...@@ -127,9 +128,9 @@ public function actions(NovaRequest $request) ...@@ -127,9 +128,9 @@ public function actions(NovaRequest $request)
$retailers = self::getRetailers(); $retailers = self::getRetailers();
return [ return [
\App\Nova\Actions\ChangeValue::make($data['field'], $data['retailer'], $retailers) \App\Nova\Actions\ChangeValue::make($data['field'], $data['retailer'], $retailers)
->confirmText('This action is used to change the value of the previously selected field in the previously selected retailer to the value of the field in the newly selected retailer') ->confirmText('This action is used to change the value of the previously selected field in the previously selected retailer to the value of the field in the newly selected retailer')
->confirmButtonText('Change') ->confirmButtonText('Change')
->cancelButtonText("Don't change"), ->cancelButtonText("Don't change"),
]; ];
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment