feat: phase 3 website pages on v1 api

This commit is contained in:
Dwindi Ramadhana
2026-02-03 22:37:52 +07:00
parent 8816522ddd
commit b1aefa6b3d
13 changed files with 563 additions and 4 deletions

View File

@@ -0,0 +1,71 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Response;
class SiteController extends Controller
{
public function home(): View
{
return view('site.home');
}
public function apiDocs(): View
{
return view('site.api-docs');
}
public function pricing(): View
{
return view('site.pricing');
}
public function privacy(): View
{
return view('site.privacy');
}
public function terms(): View
{
return view('site.terms');
}
public function emojiDetail(string $slug): View|Response
{
$dataPath = (string) config('dewemoji.data_path');
if (!is_file($dataPath)) {
abort(500, 'Emoji dataset file not found.');
}
$raw = file_get_contents($dataPath);
if ($raw === false) {
abort(500, 'Emoji dataset file could not be read.');
}
$decoded = json_decode($raw, true);
if (!is_array($decoded)) {
abort(500, 'Emoji dataset JSON is invalid.');
}
$items = $decoded['emojis'] ?? [];
$match = null;
foreach ($items as $item) {
if (($item['slug'] ?? '') === $slug) {
$match = $item;
break;
}
}
if (!$match) {
abort(404);
}
return view('site.emoji-detail', [
'emoji' => $match,
]);
}
}