<?php
/**
 *
 * @version     1.0.$Revision:$
 * @version     SVN: $Id:$
 * @package     bplan-base/globals
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025, 2026 bplan-solutions GmbH & Co. KG <http://www.bplan-solutions.de/>
 * /Δ\
 */


use BplanBase\Globals\Http\Controllers\Api\Terminal\LanguageController;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;
use LaravelJsonApi\Laravel\Facades\JsonApiRoute;
use LaravelJsonApi\Laravel\Http\Controllers\JsonApiController;
use LaravelJsonApi\Laravel\Routing\Relationships;
use LaravelJsonApi\Laravel\Routing\ResourceRegistrar;


Route::middleware(['api'])
    ->prefix('api/terminal')
    ->group(function () {
        Route::get('/health', function () {
            DB::select('SELECT 1');

            return response()->json([
                'status' => 'ok',
                'ts' => time()
            ]);

        })->name('terminal.health');
    });


JsonApiRoute::server('terminal')
    ->prefix('terminal')
    ->middleware('api')
    ->middleware('auth:sanctum')
    ->withoutMiddleware(\Illuminate\Routing\Middleware\SubstituteBindings::class)
    ->resources(function (ResourceRegistrar $Server) {

        /*
        **  Individuelle index-Route, die dafür sorgt, dass die Labels in allen Terminal-Sprachen verfügbar sind. */
        $Server->resource('languages', LanguageController::class)->only('index');

    });
