Пример #1
0
 public function getAmaotoFlow()
 {
     $flow = new Collection();
     Music::orderByRaw('RAND()')->take(10)->get()->each(function ($item) use(&$flow) {
         /** @var Music $item */
         $flow->push(['type' => 'music', 'data' => $item->toArray()]);
     });
     Album::orderByRaw('RAND()')->take(10)->get()->each(function ($item) use(&$flow) {
         /** @var Album $item */
         $flow->push(['type' => 'album', 'data' => $item->toArray()]);
     });
     $result = $flow->shuffle();
     return $this->buildResponse(trans('api.system.get-amaoto-flow.success'), Tools::toArray($result));
 }