repository = $yellowpage; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Larayellow\Yellowpage\Repositories\Criteria\YellowpageResourceCriteria::class); } /** * Display a list of yellowpage. * * @return Response */ public function index(YellowpageRequest $request) { return $this->repository ->setPresenter(\Larayellow\Yellowpage\Repositories\Presenter\YellowpagePresenter::class) ->paginate(); } /** * Display yellowpage. * * @param Request $request * @param Model $yellowpage * * @return Response */ public function show(YellowpageRequest $request, Yellowpage $yellowpage) { return $yellowpage->setPresenter(\Larayellow\Yellowpage\Repositories\Presenter\YellowpageListPresenter::class); ; } /** * Create new yellowpage. * * @param Request $request * * @return Response */ public function store(YellowpageRequest $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('yellowpage::yellowpage.name')]); $code = 204; $status = 'success'; $url = guard_url('yellowpage/yellowpage/' . $yellowpage->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('yellowpage/yellowpage'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the yellowpage. * * @param Request $request * @param Model $yellowpage * * @return Response */ public function update(YellowpageRequest $request, Yellowpage $yellowpage) { try { $data = $request->all(); $yellowpage->update($data); $message = trans('messages.success.updated', ['Module' => trans('yellowpage::yellowpage.name')]); $code = 204; $status = 'success'; $url = guard_url('yellowpage/yellowpage/' . $yellowpage->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('yellowpage/yellowpage/' . $yellowpage->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the yellowpage. * * @param Model $yellowpage * * @return Response */ public function destroy(YellowpageRequest $request, Yellowpage $yellowpage) { try { $yellowpage->delete(); $message = trans('messages.success.deleted', ['Module' => trans('yellowpage::yellowpage.name')]); $code = 202; $status = 'success'; $url = guard_url('yellowpage/yellowpage/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('yellowpage/yellowpage/' . $yellowpage->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); } }