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