59 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
use Illuminate\Http\Request;
 | 
						|
use Illuminate\Support\Facades\Route;
 | 
						|
use App\GrupoDeCompra;
 | 
						|
use App\Producto;
 | 
						|
 | 
						|
/*
 | 
						|
|--------------------------------------------------------------------------
 | 
						|
| 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!
 | 
						|
|
 | 
						|
*/
 | 
						|
 | 
						|
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');
 | 
						|
    	});
 | 
						|
    });
 | 
						|
 | 
						|
    Route::prefix('pedidos')->group(function () {
 | 
						|
        Route::get('/generar_tablas','Api\PedidoController@generarTablas');
 | 
						|
    });
 | 
						|
 | 
						|
    Route::prefix('subpedidos')->group(function () {
 | 
						|
        Route::get('/','Api\SubpedidoController@index');
 | 
						|
        Route::get('/resources', 'Api\SubpedidoController@indexResources');
 | 
						|
        Route::get('{subpedido}','Api\SubpedidoController@show');
 | 
						|
        Route::post('/','Api\SubpedidoController@store');
 | 
						|
        Route::post('/{subpedido}/sync', 'Api\SubpedidoController@syncProductos');
 | 
						|
    });
 | 
						|
 | 
						|
    Route::prefix('admin')->group(function () {
 | 
						|
        Route::prefix('subpedidos')->group(function() {
 | 
						|
            Route::post('/{subpedido}/aprobacion', 'Api\SubpedidoController@toggleAprobacion');
 | 
						|
        });
 | 
						|
    });
 | 
						|
 | 
						|
    //@TO DO -> esta ruta debe estar en middleware de auth y/o subpedido
 | 
						|
    Route::get('/categorias', function() {
 | 
						|
		return Producto::all()->pluck('categoria')->unique()->flatten();
 | 
						|
	});
 | 
						|
 | 
						|
    //@TO DO -> esta ruta debe estar en middleware de auth y/o subpedido
 | 
						|
	Route::prefix('productos')->group(function () {
 | 
						|
        Route::get('/','Api\ProductoController@index');
 | 
						|
		Route::get('{producto}','Api\ProductoController@show');
 | 
						|
	});
 | 
						|
});
 |