35 lines
		
	
	
	
		
			901 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			901 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Http\Controllers\Api;
 | |
| 
 | |
| use App\GrupoDeCompra;
 | |
| use App\Http\Controllers\Controller;
 | |
| use App\Http\Resources\GrupoDeCompraReducido;
 | |
| use App\Http\Resources\GrupoDeCompraResource;
 | |
| use http\Env\Request;
 | |
| 
 | |
| class GrupoDeCompraController extends Controller
 | |
| {
 | |
|     public function index()
 | |
|     {
 | |
|         return GrupoDeCompraResource::collection(GrupoDeCompra::all());
 | |
|     }
 | |
|     public function show(GrupoDeCompra $grupoDeCompra)
 | |
|     {
 | |
|         return new GrupoDeCompraResource($grupoDeCompra);
 | |
|     }
 | |
|     public function regiones()
 | |
|     {
 | |
|         return GrupoDeCompra::all()->pluck('region')->unique()->flatten();
 | |
|     }
 | |
| 
 | |
|     public function region(string $region)
 | |
|     {
 | |
|         return GrupoDeCompra::where('region', $region)->get();
 | |
|     }
 | |
| 
 | |
|     public function toggleDevoluciones(int $gdc) {
 | |
|         GrupoDeCompra::find($gdc)->toggleDevoluciones();
 | |
|         return response()->noContent();
 | |
|     }
 | |
| }
 |