repository = $adjustment; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Inventory\Adjustment\Repositories\Criteria\AdjustmentResourceCriteria::class); } /** * Display a list of adjustment. * * @return Response */ public function index(AdjustmentRequest $request) { return $this->repository ->setPresenter(\Inventory\Adjustment\Repositories\Presenter\AdjustmentPresenter::class) ->paginate(); } /** * Display adjustment. * * @param Request $request * @param Model $adjustment * * @return Response */ public function show(AdjustmentRequest $request, Adjustment $adjustment) { return $adjustment->setPresenter(\Inventory\Adjustment\Repositories\Presenter\AdjustmentListPresenter::class); ; } /** * Create new adjustment. * * @param Request $request * * @return Response */ public function store(AdjustmentRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('adjustment::adjustment.name')]); $code = 204; $status = 'success'; $url = guard_url('adjustment/adjustment/' . $adjustment->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('adjustment/adjustment'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the adjustment. * * @param Request $request * @param Model $adjustment * * @return Response */ public function update(AdjustmentRequest $request, Adjustment $adjustment) { try { $data = $request->all(); $adjustment->update($data); $message = trans('messages.success.updated', ['Module' => trans('adjustment::adjustment.name')]); $code = 204; $status = 'success'; $url = guard_url('adjustment/adjustment/' . $adjustment->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('adjustment/adjustment/' . $adjustment->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the adjustment. * * @param Model $adjustment * * @return Response */ public function destroy(AdjustmentRequest $request, Adjustment $adjustment) { try { $adjustment->delete(); $message = trans('messages.success.deleted', ['Module' => trans('adjustment::adjustment.name')]); $code = 202; $status = 'success'; $url = guard_url('adjustment/adjustment/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('adjustment/adjustment/' . $adjustment->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }