fix a couple things
This commit is contained in:
parent
52dc99588e
commit
6bec9cf880
1 changed files with 12 additions and 6 deletions
|
@ -43,19 +43,17 @@ class BulkAssetsController extends Controller
|
||||||
|
|
||||||
$asset_ids = array_values(array_unique($request->input('ids')));
|
$asset_ids = array_values(array_unique($request->input('ids')));
|
||||||
|
|
||||||
//custom fields logic for bulk edit
|
//custom fields logic
|
||||||
$asset_custom_field = Asset::with('model.fieldset.fields')->whereIn('id', $asset_ids)->whereHas('model', function ($query) {
|
$asset_custom_field = Asset::with(['model.fieldset.fields', 'model'])->whereIn('id', $asset_ids)->whereHas('model', function ($query) {
|
||||||
return $query->where('fieldset_id', '!=', null);
|
return $query->where('fieldset_id', '!=', null);
|
||||||
})->get();
|
})->get();
|
||||||
|
|
||||||
$models = $asset_custom_field->unique('model_id');
|
$models = $asset_custom_field->unique('model_id');
|
||||||
$modelNames = [];
|
$modelNames = [];
|
||||||
foreach($models as $model) {
|
foreach($models as $model) {
|
||||||
$modelNames[] = $model->name;
|
$modelNames[] = $model->model->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
ray($asset_custom_field);
|
|
||||||
ray($models);
|
|
||||||
// $custom_fields = new Collection();
|
// $custom_fields = new Collection();
|
||||||
// foreach ($models as $asset_key => $asset) {
|
// foreach ($models as $asset_key => $asset) {
|
||||||
// $custom_fields->push($asset->model->customFields);
|
// $custom_fields->push($asset->model->customFields);
|
||||||
|
@ -82,7 +80,7 @@ class BulkAssetsController extends Controller
|
||||||
->with('assets', $asset_ids)
|
->with('assets', $asset_ids)
|
||||||
->with('statuslabel_list', Helper::statusLabelList())
|
->with('statuslabel_list', Helper::statusLabelList())
|
||||||
// ->with('custom_fields', $custom_fields)
|
// ->with('custom_fields', $custom_fields)
|
||||||
->with('models', $models->pluck('model'))
|
->with('models', $models->pluck(['model']))
|
||||||
->with('modelNames', $modelNames);
|
->with('modelNames', $modelNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +99,7 @@ class BulkAssetsController extends Controller
|
||||||
public function update(Request $request)
|
public function update(Request $request)
|
||||||
{
|
{
|
||||||
$this->authorize('update', Asset::class);
|
$this->authorize('update', Asset::class);
|
||||||
|
$error_bag = [];
|
||||||
|
|
||||||
// Get the back url from the session and then destroy the session
|
// Get the back url from the session and then destroy the session
|
||||||
$bulk_back_url = route('hardware.index');
|
$bulk_back_url = route('hardware.index');
|
||||||
|
@ -219,7 +218,14 @@ class BulkAssetsController extends Controller
|
||||||
$asset->update($array);
|
$asset->update($array);
|
||||||
$asset->save();
|
$asset->save();
|
||||||
}
|
}
|
||||||
|
if (!$asset->save()) {
|
||||||
|
$error_bag[] = $asset;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!$asset->save()) {
|
||||||
|
return redirect()->back()->withInput()->withErrors('One of your custom fields is not valid.');
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Asset::find($assetId)->update($this->update_array);
|
Asset::find($assetId)->update($this->update_array);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue