$request->price , "date_at"=>date("Y-m-d"), "time_at"=>now()->format("H:m:s"), "user_id"=>auth('user')->id() ]); $candle = PriceCandle::whereDate('date_at',date("Y-m-d"))->first(); if (!is_null($candle)){ $candle->end = $request->price; if ($request->price < $candle->low){ $candle->low = $request->price; } elseif ($request->price > $candle->high){ $candle->high = $request->price; } $candle->save(); }else{ PriceCandle::create([ "start"=>$request->price, "end"=>$request->price, "high"=>$request->price, "low"=>$request->price, "date_at"=>date("Y-m-d") ]); } return response()->json(true); } public function priceData(Request $request){ $prise = Price::with('order'); TableEngine::create($prise, $request) ->initSearch(['price']) ->select(['*']) ->export($prise); return response()->json($prise); } public function chartPrices(ZaarboxPriceService $zaarboxPriceService) { return response()->json([ 'code' => 0, 'message' => 'عملیات با موفقیت انجام شد.', 'data' => [ 'prices' => $zaarboxPriceService->getAllPrices(), ], ]); } public function table(Request $request){ $records = Price::with(['user']); TableEngine::create($records, $request->all()) ->initSearch([]) ->select([ '*' ])->export($records); return response()->json($records); } }