where('release_date', '<=', $now) ->where('release_date', '>', $week_ago) ->orderBy('source') ->get(); $gamebooks = []; $quests_ru = []; $quests_en = []; $visualnovels = []; $ru = Language::findByCode('ru'); foreach ($games as $game) { $tags = $game->tags->pluck('title',' id')->toArray(); $tags = array_values($tags); $tags = array_map('strtolower', $tags); if (array_intersect([ 'adult', 'xxx', '18+', 'porn', 'porngame', 'pointnclick', 'lewd', 'erotic', 'nsfw', 'bitsy', 'vr', ], $tags) !== []) { continue; } if (strpos($game->title, 'PDF') !== false) { $gamebooks[] = $game; } else if ($game->source === 'Anivisual') { $visualnovels[] = $game; } else if ($game->languages->where('id', $ru->id)->first()) { $quests_ru[] = $game; } else { if (empty($quests_en[$game->source])) { $quests_en[$game->source] = []; } $quests_en[$game->source][] = $game; } } if (!empty($gamebooks)) { $this->printList('Книги-игры', $gamebooks); } if (!empty($visualnovels)) { $this->printList('Визуальные новеллы', $visualnovels); } if (!empty($quests_ru)) { $this->printList('Текстовые квесты', $quests_ru); } if (!empty($quests_en)) { foreach ($quests_en as $source => $list) { $this->printSpoiler($source, $list); } } } protected function printSpoiler($title, $list) { echo ''; $this->printList($title, $list); echo ''; } protected function printList($title, $list) { echo '

'.$title.'

'.PHP_EOL; } protected function printGame($game) { echo '
  • '; $authors = $game->authors->toArray(); if (!empty($authors)) { echo ''; echo implode(', ', array_map(function($model) { return trim($model['name']); }, $authors)); echo ' — '; } echo "«".htmlentities(trim($game->title))."»"; $description = $game->short_description; if (empty($description)) { $description = $game->description; } if (!empty($description)) { echo PHP_EOL.'
    '.$game->normalizeDescription($description).'
    '; } echo '
  • '.PHP_EOL; } }