finished laravel migration
This commit is contained in:
22
app/Http/Controllers/I18nController.php
Normal file
22
app/Http/Controllers/I18nController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class I18nController extends Controller
|
||||
{
|
||||
public function __invoke(string $locale): JsonResponse
|
||||
{
|
||||
$path = resource_path("lang/{$locale}.json");
|
||||
|
||||
if (!File::exists($path)) {
|
||||
return response()->json([], 404);
|
||||
}
|
||||
|
||||
$contents = File::get($path);
|
||||
|
||||
return response()->json(json_decode($contents, true, 512, JSON_THROW_ON_ERROR));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user