/** * Execute the console command. * * @return mixed */ public function handle() { $genres = $this->genreService->getAllGenres(); foreach ($genres as $genre) { Genre::updateOrCreate(['name' => $genre['name']], ['name' => $genre['name'], 'approved' => true]); } }
/** * Execute the console command. * * @return mixed */ public function handle() { Genre::query()->update(['approved' => false]); $genres = explode("\n", file_get_contents("php://stdin")); foreach ($genres as $genre) { $query = Genre::where('name', $genre); if ($query->exists()) { $query->update(['approved' => true]); } else { Genre::create(['name' => $genre, 'approved' => true]); } } }
protected function getRandomGenres() { return Genre::where('approved', true)->orderBy(DB::raw('random()'))->limit(config('rock_expert.tasks.count'))->get()->toArray(); }
protected function getMainGenre($genres) { return array_first($genres, function ($i, $genre) { return Genre::where('name', $genre)->exists(); }); }
/** * Execute the console command. * * @return mixed */ public function handle() { app(EchoNestService::class)->updateArtists(Genre::all()); }