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