30 lines
1.1 KiB
PHP
30 lines
1.1 KiB
PHP
<?php namespace App\Http\Controllers\Dashboard;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\Controller as BaseController;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class TramiteController extends BaseController
|
|
{
|
|
public function tramiteEspecial(Request $request)
|
|
{
|
|
$query = $request->only(['start', 'end', 'type']);
|
|
$query = array_merge(['type' => 'api'], $query);
|
|
|
|
try {
|
|
$response = Http::timeout(5)->get('https://tramites.comalcalco.gob.mx/reporte-especial', $query);
|
|
|
|
if (! $response->successful()) {
|
|
return response()->json(['error' => 'External service error'], $response->status());
|
|
}
|
|
|
|
return response()->json($response->json(), $response->status())
|
|
->header('Content-Type', $response->header('Content-Type', 'application/json'));
|
|
} catch (\Throwable $e) {
|
|
Log::error('Proxy error: '.$e->getMessage());
|
|
return response()->json(['error' => 'Unable to contact external service'], 502);
|
|
}
|
|
}
|
|
}
|