Agregada metodo para togglear devoluciones + ruta de api
This commit is contained in:
		
							parent
							
								
									9e7eb89014
								
							
						
					
					
						commit
						75b7507bbe
					
				
					 2 changed files with 17 additions and 6 deletions
				
			
		|  | @ -17,6 +17,13 @@ class GrupoDeCompra extends Model | |||
|   protected $table = 'grupos_de_compra'; | ||||
|   protected $hidden = ['password']; | ||||
| 
 | ||||
|   public function toggleDevoluciones() | ||||
|   { | ||||
|       $this->devoluciones_habilitadas = !$this->devoluciones_habilitadas; | ||||
|       $this->save(); | ||||
|       return $this->devoluciones_habilitadas; | ||||
|   } | ||||
| 
 | ||||
|   public function subpedidos() { | ||||
|   	return $this->hasMany('App\Subpedido'); | ||||
|   } | ||||
|  |  | |||
|  | @ -36,9 +36,13 @@ Route::middleware('api')->group(function () { | |||
|             $grupo = GrupoDeCompra::where('id',$gdc)->first(); | ||||
|             return ['bonos_barriales' => $grupo->totalBonosBarriales()]; | ||||
|         }); | ||||
|         Route::get('/{gdc}/devoluciones-habilitadas', function($gdc) { | ||||
|         Route::get('/{gdc}/devoluciones', function($gdc) { | ||||
|             $habilitadas = GrupoDeCompra::where('id',$gdc)->value('devoluciones_habilitadas'); | ||||
|             return ['devoluciones_habilitadas' => $habilitadas]; | ||||
|             return ['devoluciones' => $habilitadas]; | ||||
|         }); | ||||
|         Route::post('/{gdc}/devoluciones', function($gdc) { | ||||
|             $habilitadas = GrupoDeCompra::where('id',$gdc)->toggleDevoluciones(); | ||||
|             return ['devoluciones' => $habilitadas]; | ||||
|         }); | ||||
|     }); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue