feat: phase 3 website pages on v1 api
This commit is contained in:
71
app/app/Http/Controllers/Web/SiteController.php
Normal file
71
app/app/Http/Controllers/Web/SiteController.php
Normal 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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user