/** * 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 getMainGenre($genres) { return array_first($genres, function ($i, $genre) { return Genre::where('name', $genre)->exists(); }); }
protected function getRandomGenres() { return Genre::where('approved', true)->orderBy(DB::raw('random()'))->limit(config('rock_expert.tasks.count'))->get()->toArray(); }