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