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