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