Files
deepseek fff7a4b9b9 GG.deals clone: CodeIgniter 4 + MongoDB game price tracker
- Full gg.deals-style UI: deal feed with filters, game pages with price
  history charts, rankings, vouchers, news, prepaids, subscriptions,
  bundles, franchises, wishlist, API docs
- Real data crawlers:
  * gg:crawl (Steam Store API + GOG Catalog + Epic free games)
  * gg:catalog (252K game slugs from gg.deals sitemaps)
  * gg:ggdeals (per-game prices via FlareSolverr session, JSON-LD parsing)
  * gg:seed / gg:crawl-covers (demo seed + Steam CDN cover art)
- 24/7 self-updating scheduler (scripts/scheduler_loop.php, lockfile-protected)
- Tailwind v4 dark/light theme, Alpine.js, Chart.js
2026-08-23 07:06:02 +00:00

68 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Controllers;
use App\Libraries\Mongo;
use CodeIgniter\Controller;
class News extends Controller
{
private const CATEGORIES = [
'' => 'All news',
'deals' => 'Deals',
'bundles' => 'Bundles',
'freebies' => 'Freebies',
'giveaways' => 'Giveaways',
'subscriptions' => 'Subscriptions',
];
public function index(string $cat = ''): string
{
if (! isset(self::CATEGORIES[$cat])) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
}
$filter = $cat !== '' ? ['category' => $cat] : [];
$posts = Mongo::collection('news')
->find($filter, ['sort' => ['date' => -1], 'limit' => 40])
->toArray();
$data = [
'pageTitle' => 'Video game news — GG.deals',
'posts' => $posts,
'cats' => self::CATEGORIES,
'active' => $cat,
];
return view('news', $data);
}
public function article(string $slug): string
{
$post = Mongo::collection('news')->findOne(['slug' => $slug]);
if ($post === null) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
}
$related = Mongo::collection('news')
->find(
['slug' => ['$ne' => $slug], 'category' => $post['category']],
['sort' => ['date' => -1], 'limit' => 4]
)
->toArray();
$data = [
'pageTitle' => $post['title'] . ' — GG.deals',
'post' => $post,
'related' => $related,
'cats' => self::CATEGORIES,
'active' => $post['category'],
];
return view('news_article', $data);
}
}