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