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