pedi2/routes/api.php

75 lines
3.0 KiB
PHP
Raw Permalink Normal View History

2021-12-30 11:49:40 -03:00
<?php
2023-06-07 22:21:21 -03:00
use App\Filtros\FiltroDeProducto;
use App\Filtros\FiltroDeSubpedido;
2021-12-30 11:49:40 -03:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\GrupoDeCompra;
2022-01-05 18:14:21 -03:00
use App\Producto;
2021-12-30 11:49:40 -03:00
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
2022-01-06 16:20:21 -03:00
Route::middleware('api')->group(function () {
Route::get('/regiones', function() {
return GrupoDeCompra::all()->pluck('region')->unique()->flatten();
});
Route::prefix('grupos-de-compra')->group( function(){
Route::get('/', function() {
$atributos_a_ocultar = ['telefono', 'cantidad_de_nucleos', 'correo', 'referente_finanzas', 'created_at', 'updated_at'];
return GrupoDeCompra::all()->makeHidden($atributos_a_ocultar)->sortBy('nombre')->groupBy('region');
});
2023-06-07 22:21:21 -03:00
Route::get('/{gdc}/bonos-de-transporte', function($gdc) {
$grupo = GrupoDeCompra::where('id',$gdc)->first();
return ['bdt' => $grupo->calcularCantidadBDT()];
});
2023-10-04 22:37:59 -03:00
Route::get('/{gdc}/bonos-barriales', function($gdc) {
$grupo = GrupoDeCompra::where('id',$gdc)->first();
return ['bonos_barriales' => $grupo->totalBonosBarriales()];
});
Route::get('/{gdc}/devoluciones', function($gdc) {
$habilitadas = GrupoDeCompra::find($gdc)->devoluciones_habilitadas;
return ['devoluciones' => $habilitadas];
});
Route::post('/{gdc}/devoluciones', function($gdc) {
$habilitadas = GrupoDeCompra::find($gdc)->toggleDevoluciones();
return ['devoluciones' => $habilitadas];
});
});
2022-01-05 18:14:21 -03:00
2022-01-12 10:53:44 -03:00
Route::prefix('subpedidos')->group(function () {
Route::get('/','Api\SubpedidoController@index');
Route::get('/resources', 'Api\SubpedidoController@indexResources');
Route::get('{subpedido}','Api\SubpedidoController@show');
2022-01-12 10:53:44 -03:00
Route::post('/','Api\SubpedidoController@store');
Route::post('/{subpedido}/sync', 'Api\SubpedidoController@syncProductos');
Route::post('/{subpedido}/sync_devoluciones', 'Api\SubpedidoController@syncDevoluciones');
2022-01-12 10:53:44 -03:00
});
Route::prefix('admin')->group(function () {
Route::prefix('subpedidos')->group(function() {
Route::post('/{subpedido}/aprobacion', 'Api\SubpedidoController@toggleAprobacion');
});
});
2022-01-12 10:53:44 -03:00
//@TO DO -> esta ruta debe estar en middleware de auth y/o subpedido
2022-01-05 18:14:21 -03:00
Route::get('/categorias', function() {
return Producto::all()->pluck('categoria')->unique()->flatten();
});
2022-01-12 10:53:44 -03:00
//@TO DO -> esta ruta debe estar en middleware de auth y/o subpedido
2022-01-05 18:14:21 -03:00
Route::prefix('productos')->group(function () {
2022-01-12 10:53:44 -03:00
Route::get('/','Api\ProductoController@index');
Route::get('{producto}','Api\ProductoController@show');
2022-01-05 18:14:21 -03:00
});
2021-12-30 11:49:40 -03:00
});