65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class GloboERPController extends Controller
|
|
{
|
|
protected int $sitio_web;
|
|
protected int $status;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->sitio_web = config('sitioweb.sitio_web_erp_id', 0);
|
|
$this->status = 1;
|
|
}
|
|
|
|
public function getNombresImagenGlobosActivos()
|
|
{
|
|
try {
|
|
|
|
$baseUrl = 'https://erp.skyballoons.mx/assets/images/globos/';
|
|
|
|
$globos = DB::table('globos')
|
|
->select('nombre_globo', 'ruta_imagen')
|
|
->where('estatus_globo', $this->status)
|
|
->where('id_estatus', $this->status)
|
|
->where('empresa', 'sky')
|
|
->get()
|
|
->map(function ($globo) use ($baseUrl) {
|
|
|
|
if (!empty($globo->ruta_imagen)) {
|
|
|
|
// Si ya es URL completa la dejamos igual
|
|
if (!filter_var($globo->ruta_imagen, FILTER_VALIDATE_URL)) {
|
|
|
|
$archivo = ltrim($globo->ruta_imagen, '/');
|
|
|
|
$globo->ruta_imagen = $baseUrl . $archivo;
|
|
}
|
|
}
|
|
|
|
return $globo;
|
|
});
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'data' => $globos
|
|
]);
|
|
} catch (\Throwable $e) {
|
|
|
|
Log::error('Error obteniendo globos activos', [
|
|
'message' => $e->getMessage()
|
|
]);
|
|
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => 'No se pudieron obtener los globos'
|
|
], 500);
|
|
}
|
|
}
|
|
}
|