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