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