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