where(['adp_id' => $item['id'], 'type' => 1, 'status' => 1])->limit(8)->get()->toArray(); $ad = $this->getService()->ad_arrange($ad); $item['new_ad'] = $ad; $ad = AdModel::with('translation')->where(['adp_id' => $item['id'], 'type' => 2, 'status' => 1])->limit(8)->get()->toArray(); $ad = $this->getService()->ad_arrange($ad); $item['used_ad'] = $ad; } return $item; } /** * 参数预处理 (根据场景处理) * @param Request $request * @param string $scene * @return array */ protected function prepareParams(Request $request, string $scene): array { $params = parent::prepareParams($request, $scene); if ($scene === 'default') { $params['filters'] = []; } return $params; } /** * 分页 * * @param Request $request 请求对象 * @return Response 响应对象 */ public function index(Request $request, string $scene = 'default'): Response { try { return parent::index($request, $scene); } catch (\Throwable $th) { return $this->errorResponse($th->getMessage()); } } }