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