banner
parent
aed7cf155f
commit
23c6bc2a53
|
|
@ -23,19 +23,13 @@ class BannerController extends Controller
|
||||||
},
|
},
|
||||||
])->enable()->whereIn('key', $keys)->get();
|
])->enable()->whereIn('key', $keys)->get();
|
||||||
|
|
||||||
$mapAds = $ads->mapWithKeys(function ($item) use ($request) {
|
$data = [];
|
||||||
return [
|
|
||||||
$item->key => BannerResource::collection($item->banners)->resolve($request),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
if (! $mapAds->has($key)) {
|
$ad = $ads->where('key', $key)->first();
|
||||||
$mapAds->put($key, []);
|
$data[$key] = $ad ? BannerResource::collection($ad->banners) : [];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->json($mapAds);
|
return $this->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue