Skip to content
Snippets Groups Projects
Commit a655bd01 authored by Shizuco's avatar Shizuco
Browse files

update: messages for user

parent 7e7fbff8
No related branches found
No related tags found
1 merge request!4Dctn 494/fix
......@@ -35,7 +35,7 @@ public function handle(ActionFields $fields, Collection $models)
$retailersValue = Product::where('retailer_id', $fields->fromRetailer)->where('sku', $model['sku'])->select($this->field)->first();
if(!$retailersValue)
{
return Action::danger('Error!');
return Action::danger('Of the selected products, not all retailers have a qualifying product!');
}
Product::where('retailer_id', $this->retailer)->where('sku', $model['sku'])->update([$this->field => $retailersValue[$this->field]]);
}
......
......@@ -21,18 +21,28 @@ public static function query(LensRequest $request, $query)
$data = self::getDataFromUrl();
if ($data) {
$existFields = Product::where('retailer_id', $data['retailer'])->pluck('sku')->all();
return $query
->where('retailer_id', '!=', $data['retailer'])
->whereIn('sku', $existFields)
->join('retailers as r', 'products.retailer_id', '=', 'r.id')
->select(
$returnQuery = $query
->where('retailer_id', '!=', $data['retailer'])
->whereIn('sku', $existFields)
->join('retailers as r', 'products.retailer_id', '=', 'r.id');
if($data['field'] === 'name')
{
$returnQuery->select(
'sku',
DB::raw('group_concat(products.id) as id'),
DB::raw('group_concat(products.name) as name'),
DB::raw('group_concat(r.id) as retailer_id'));
}
else{
$returnQuery->select(
'sku',
DB::raw('group_concat(products.id) as id'),
DB::raw('group_concat(' . $data['field'] . ') as ' . $data['field']),
DB::raw('group_concat(products.name) as name'),
DB::raw('group_concat(r.id) as retailer_id'))
->groupBy('sku');
DB::raw('group_concat(r.id) as retailer_id'));
}
$returnQuery->groupBy('sku');
return $returnQuery;
}
}
......@@ -68,7 +78,7 @@ public function fields(NovaRequest $request)
array_push($fields,
Text::make($retailer . ' ' . $data['field'], function () use ($count, $data) {
$field = $data['field'];
$fields = explode(',', $this->$field);
$fields = explode(',', $this[$field]);
if (count($fields) < $count + 1) {
return null;
}
......@@ -116,7 +126,10 @@ public function actions(NovaRequest $request)
$data = self::getDataFromUrl();
$retailers = self::getRetailers();
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')
->confirmButtonText('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