From 4376586a231aa245b14ae209d77f34f61c25d761 Mon Sep 17 00:00:00 2001 From: Ale Date: Sun, 12 Nov 2023 20:13:17 -0300 Subject: [PATCH] agregado campo y ruta para togglear devoluciones --- app/GrupoDeCompra.php | 2 +- ...23_11_12_145219_habilitar_devoluciones.php | 32 +++++++++++++++++++ routes/api.php | 4 +++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2023_11_12_145219_habilitar_devoluciones.php diff --git a/app/GrupoDeCompra.php b/app/GrupoDeCompra.php index 09ec62b..2f9ad4e 100644 --- a/app/GrupoDeCompra.php +++ b/app/GrupoDeCompra.php @@ -13,7 +13,7 @@ use League\Csv\Reader; class GrupoDeCompra extends Model { public $timestamps = false; - protected $fillable = [ "nombre","region","telefono","correo","referente_finanzas","cantidad_de_nucleos","fila"]; + protected $fillable = [ "nombre","region","telefono","correo","referente_finanzas","cantidad_de_nucleos","fila", "devoluciones_habilitadas"]; protected $table = 'grupos_de_compra'; protected $hidden = ['password']; diff --git a/database/migrations/2023_11_12_145219_habilitar_devoluciones.php b/database/migrations/2023_11_12_145219_habilitar_devoluciones.php new file mode 100644 index 0000000..e94da1d --- /dev/null +++ b/database/migrations/2023_11_12_145219_habilitar_devoluciones.php @@ -0,0 +1,32 @@ +boolean('devoluciones_habilitadas')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('grupos_de_compra', function (Blueprint $table) { + $table->dropColumn('devoluciones_habilitadas'); + }); + } +} diff --git a/routes/api.php b/routes/api.php index b21e7bc..d1ebbe4 100644 --- a/routes/api.php +++ b/routes/api.php @@ -36,6 +36,10 @@ Route::middleware('api')->group(function () { $grupo = GrupoDeCompra::where('id',$gdc)->first(); return ['bonos_barriales' => $grupo->totalBonosBarriales()]; }); + Route::get('/{gdc}/devoluciones-habilitadas', function($gdc) { + $habilitadas = GrupoDeCompra::where('id',$gdc)->value('devoluciones_habilitadas'); + return ['devoluciones_habilitadas' => $habilitadas]; + }); }); Route::prefix('subpedidos')->group(function () {