actionOfQuickEdit()) { $result = $this->service->quickEdit($request->all()); } elseif ($this->actionOfQuickEditItem()) { $result = $this->service->quickEditItem($request->all()); } else { $result = $this->service->store($request->all()); } if (! $result) { admin_abort($this->service->getError() ?: __('admin.save') . __('admin.failed')); } DB::commit(); } catch (Throwable $th) { DB::rollBack(); throw $th; } return $this->response()->successMessage(__('admin.save') . __('admin.successfully')); } /** * {@inheritdoc} */ public function update(Request $request) { $input = Arr::except($request->all(), $this->service->primaryKey()); if ($request->filled('_fields')) { $input = Arr::only($input, explode(',', $request->input('_fields'))); } try { DB::beginTransaction(); $result = $this->service->update($this->getPrimaryValue($request), $input); if (! $result) { admin_abort($this->service->getError() ?: __('admin.save') . __('admin.failed')); } DB::commit(); } catch (Throwable $th) { DB::rollBack(); throw $th; } return $this->response()->successMessage(__('admin.save') . __('admin.successfully')); } /** * {@inheritdoc} */ public function destroy($ids) { try { DB::beginTransaction(); $this->service->delete($ids); DB::commit(); } catch (Throwable $th) { DB::rollBack(); throw $th; } return $this->response()->successMessage(__('admin.delete') . __('admin.successfully')); } public function getQuickEditItemPath(array $fields = ['*']) { $path = $this->getUpdatePath(); if ($fields != ['*']) { $path .= '?_fields='.implode(',', $fields); } return $path; } }