vueloenglobo.mx/app/Http/Controllers/ApiVuelosController.php

125 lines
3.3 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ApiVuelosController extends Controller
{
/**
* Obtener todos los vuelos por sitio web
*/
public static function getBySitioWeb($sitioId = 6)
{
return DB::table('vuelos')
->where('id_sitio_web', $sitioId)
->where('id_estatus', 1)
->get();
}
/**
* Obtener vuelos con categoría
*/
public static function getWithCategoria($sitioId = 6)
{
return DB::table('vuelos as v')
->join('categorias_vuelos as c', 'v.id_categoria', '=', 'c.id_categoria')
->select(
'v.*',
'c.nombre_categoria'
)
->where('v.id_sitio_web', $sitioId)
->where('v.id_estatus', 1)
->get();
}
/**
* Obtener vuelos con precios
*/
public static function getWithPrecios($sitioId = 6)
{
return DB::table('vuelos as v')
->leftJoin('vuelos_precios as p', 'v.id_vuelo', '=', 'p.id_vuelo')
->select(
'v.id_vuelo',
'v.nombre_vuelo',
'p.precio_vuelo_original',
'p.precio_vuelo_especial',
'p.moneda_precio'
)
->where('v.id_sitio_web', $sitioId)
->where('v.id_estatus', 1)
->get();
}
/**
* Obtener vuelos con imágenes
*/
public static function getWithGaleria($sitioId = 6)
{
return DB::table('vuelos as v')
->leftJoin('vuelos_imagenes_galeria as g', 'v.id_vuelo', '=', 'g.id_vuelo')
->select(
'v.id_vuelo',
'v.nombre_vuelo',
'g.ruta_imagen_vuelo',
'g.imagen_destacada'
)
->where('v.id_sitio_web', $sitioId)
->where('v.id_estatus', 1)
->get();
}
/**
* Obtener vuelos con items incluidos
*/
public static function getWithIncluye($vueloId)
{
return DB::table('vuelos_items_incluye')
->where('id_vuelo', $vueloId)
->where('id_estatus', 1)
->get();
}
/**
* Obtener fechas bloqueadas de un vuelo
*/
public static function getFechasBloqueadas($vueloId)
{
return DB::table('fechas_vuelos_bloqueadas')
->where('id_vuelo', $vueloId)
->where('id_estatus', 1)
->pluck('fechas_vuelo');
}
/**
* Obtener fechas disponibles para venta
*/
public static function getFechasVenta($vueloId)
{
return DB::table('vuelos_fechas_venta')
->where('id_vuelo', $vueloId)
->where('id_estatus', 1)
->pluck('fecha_venta');
}
/**
* Obtener vuelos con precios en USD
*/
public static function getVuelosUSD($sitioId = 6)
{
return DB::table('vuelos as v')
->join('vuelos_usd as u', 'v.id_vuelo', '=', 'u.id_vuelo')
->select(
'v.id_vuelo',
'v.nombre_vuelo',
'u.precio_usd',
'u.precio_especial_usd'
)
->where('v.id_sitio_web', $sitioId)
->where('v.id_estatus', 1)
->get();
}
}