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