- 134-tool registry with programmatic SEO (unique titles/H1/descriptions, JSON-LD graphs, sitemap index, canonical 301 enforcement via required filter) - DB-backed job queue (SKIP LOCKED) with drivers: Ffmpeg, Images (GD), Pdf (qpdf/gs/poppler), Youtube (thumbnails), Qr (server-side PNG) - Security: SSRF guard, MIME validation, rate limits, API-key auth, bcrypt admin login, security headers - Admin panel: dashboard, tools/categories/guides CRUD, SEO audit, analytics, job inspector with retry, system health, feature flags - Docker deployment (nginx + web/api FPM pools + scalable workers), PHPUnit suite (19 tests / 1139 assertions), PWA manifest + service worker
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
final class GuideModel extends Model
|
|
{
|
|
protected $table = 'guides';
|
|
protected $primaryKey = 'id';
|
|
protected $returnType = 'array';
|
|
protected $useTimestamps = true;
|
|
protected $allowedFields = [
|
|
'slug', 'title', 'excerpt', 'body_md', 'tool_slugs', 'category_id',
|
|
'seo_title', 'seo_description', 'reading_minutes', 'views', 'status', 'published_at',
|
|
];
|
|
|
|
public function findBySlug(string $slug): ?array
|
|
{
|
|
return $this->where('slug', $slug)->where('status', 'published')->first();
|
|
}
|
|
|
|
/** @return list<array> */
|
|
public function published(int $limit = 50, int $offset = 0): array
|
|
{
|
|
return $this->where('status', 'published')
|
|
->orderBy('published_at', 'DESC')
|
|
->limit($limit, $offset)
|
|
->findAll();
|
|
}
|
|
|
|
public function countPublished(): int
|
|
{
|
|
return $this->where('status', 'published')->countAllResults();
|
|
}
|
|
|
|
public function incrementViews(int $id): void
|
|
{
|
|
$this->builder()->set('views', 'views+1', false)->where('id', $id)->update();
|
|
}
|
|
}
|