repository = $push_notification; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Location\PushNotification\Repositories\Criteria\PushNotificationResourceCriteria::class); } /** * Display a list of push_notification. * * @return Response */ public function index(PushNotificationRequest $request) { return $this->repository ->setPresenter(\Location\PushNotification\Repositories\Presenter\PushNotificationPresenter::class) ->paginate(); } /** * Display push_notification. * * @param Request $request * @param Model $push_notification * * @return Response */ public function show(PushNotificationRequest $request, PushNotification $push_notification) { return $push_notification->setPresenter(\Location\PushNotification\Repositories\Presenter\PushNotificationListPresenter::class); ; } /** * Create new push_notification. * * @param Request $request * * @return Response */ public function store(PushNotificationRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('push_notification::push_notification.name')]); $code = 204; $status = 'success'; $url = guard_url('push_notification/push_notification/' . $push_notification->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('push_notification/push_notification'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the push_notification. * * @param Request $request * @param Model $push_notification * * @return Response */ public function update(PushNotificationRequest $request, PushNotification $push_notification) { try { $data = $request->all(); $push_notification->update($data); $message = trans('messages.success.updated', ['Module' => trans('push_notification::push_notification.name')]); $code = 204; $status = 'success'; $url = guard_url('push_notification/push_notification/' . $push_notification->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('push_notification/push_notification/' . $push_notification->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the push_notification. * * @param Model $push_notification * * @return Response */ public function destroy(PushNotificationRequest $request, PushNotification $push_notification) { try { $push_notification->delete(); $message = trans('messages.success.deleted', ['Module' => trans('push_notification::push_notification.name')]); $code = 202; $status = 'success'; $url = guard_url('push_notification/push_notification/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('push_notification/push_notification/' . $push_notification->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }