repository = $deposit_plan_history; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\History\Repositories\Criteria\DepositPlanHistoryResourceCriteria::class); } /** * Display a list of deposit_plan_history. * * @return Response */ public function index(DepositPlanHistoryRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\History\Repositories\Presenter\DepositPlanHistoryPresenter::class) ->$function(); } $deposit_plan_histories = $this->repository->paginate(); return $this->response->title(trans('history::deposit_plan_history.names')) ->view('history::deposit_plan_history.index', true) ->data(compact('deposit_plan_histories')) ->output(); } /** * Display deposit_plan_history. * * @param Request $request * @param Model $deposit_plan_history * * @return Response */ public function show(DepositPlanHistoryRequest $request, DepositPlanHistory $deposit_plan_history) { if ($deposit_plan_history->exists) { $view = 'history::deposit_plan_history.show'; } else { $view = 'history::deposit_plan_history.new'; } return $this->response->title(trans('app.view') . ' ' . trans('history::deposit_plan_history.name')) ->data(compact('deposit_plan_history')) ->view($view, true) ->output(); } /** * Show the form for creating a new deposit_plan_history. * * @param Request $request * * @return Response */ public function create(DepositPlanHistoryRequest $request) { $deposit_plan_history = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('history::deposit_plan_history.name')) ->view('history::deposit_plan_history.create', true) ->data(compact('deposit_plan_history')) ->output(); } /** * Create new deposit_plan_history. * * @param Request $request * * @return Response */ public function store(DepositPlanHistoryRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $deposit_plan_history = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('history::deposit_plan_history.name')])) ->code(204) ->status('success') ->url(guard_url('history/deposit_plan_history/' . $deposit_plan_history->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/history/deposit_plan_history')) ->redirect(); } } /** * Show deposit_plan_history for editing. * * @param Request $request * @param Model $deposit_plan_history * * @return Response */ public function edit(DepositPlanHistoryRequest $request, DepositPlanHistory $deposit_plan_history) { return $this->response->title(trans('app.edit') . ' ' . trans('history::deposit_plan_history.name')) ->view('history::deposit_plan_history.edit', true) ->data(compact('deposit_plan_history')) ->output(); } /** * Update the deposit_plan_history. * * @param Request $request * @param Model $deposit_plan_history * * @return Response */ public function update(DepositPlanHistoryRequest $request, DepositPlanHistory $deposit_plan_history) { try { $attributes = $request->all(); $deposit_plan_history->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('history::deposit_plan_history.name')])) ->code(204) ->status('success') ->url(guard_url('history/deposit_plan_history/' . $deposit_plan_history->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('history/deposit_plan_history/' . $deposit_plan_history->getRouteKey())) ->redirect(); } } /** * Remove the deposit_plan_history. * * @param Model $deposit_plan_history * * @return Response */ public function destroy(DepositPlanHistoryRequest $request, DepositPlanHistory $deposit_plan_history) { try { $deposit_plan_history->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('history::deposit_plan_history.name')])) ->code(202) ->status('success') ->url(guard_url('history/deposit_plan_history/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('history/deposit_plan_history/' . $deposit_plan_history->getRouteKey())) ->redirect(); } } /** * Remove multiple deposit_plan_history. * * @param Model $deposit_plan_history * * @return Response */ public function delete(DepositPlanHistoryRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('history::deposit_plan_history.name')])) ->status("success") ->code(202) ->url(guard_url('history/deposit_plan_history')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/history/deposit_plan_history')) ->redirect(); } } /** * Restore deleted deposit_plan_histories. * * @param Model $deposit_plan_history * * @return Response */ public function restore(DepositPlanHistoryRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('history::deposit_plan_history.name')])) ->status("success") ->code(202) ->url(guard_url('/history/deposit_plan_history')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/history/deposit_plan_history/')) ->redirect(); } } }