public function q(Request $request) { $search = $request->input("q"); //todo: parse 'q' in separate class and return an array of parameters. // See: https://developer.github.com/v3/search/#search-repositories $matches = []; //look specifically for field limiter 'in' $match = preg_match('/^(?<q>.*)\\bin:(?<in>.*)/us', $search, $matches[]); if ($match) { //just look for uri if (isset($matches[0]['in'])) { $fields = explode(',', $matches[0]['in']); foreach ($fields as $field) { if ('uri' == $field) { //lookup the uri in elements $element = $this->elementRepository->findBy('uri', $matches[0]['q']); if ($element) { return $this->sendResponse($element->toArray(), "element found"); } //lookup the uri in concepts $concept = $this->conceptRepository->findBy('uri', $matches[0]['q']); if ($concept) { return $this->sendResponse($concept->toArray(), "concept found"); } } else { } } } } }
public function store(Request $request) { //Need to improve how to get user from Token and handle possible errors such as token expired. $user = JWTAuth::parseToken()->authenticate(); $order = new Order(); $order->user_id = $user->id; $order->order_status_id = 1; $order->save(); //Get all the items $data = $request->input('data'); $items = $data['items']; foreach ($items as $key => $value) { $arr[$key] = new OrderItem(); $arr[$key]->order_id = $order->id; $arr[$key]->item_id = $value['id']; $arr[$key]->quantity = $value['quantity']; $arr[$key]->price = $value['price']; //$arr[$key]->notes = $value['notes']; } $order->orderItems()->saveMany($arr); return $this->success('Pedido Criado'); }
/** * Parse the includes. * * @param \Dingo\Api\Http\Request $request * * @return void */ public function parseFractalIncludes(Request $request) { $includes = $request->input($this->includeKey); if (!is_array($includes)) { $includes = array_filter(explode($this->includeSeparator, $includes)); } $this->fractal->parseIncludes($includes); }
/** * Handle an incoming request. * * @param \Dingo\Api\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $search = $request->input('q'); $bar = $request->getQueryString(); return $next($request); }