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