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