Compare commits
7 commits
929191f173
...
87c3bb207f
Author | SHA1 | Date | |
---|---|---|---|
87c3bb207f | |||
d7c3ed857c | |||
b0ac8f538c | |||
7a7cd678ad | |||
e9a6def7c1 | |||
53dc4d735e | |||
a74f89f684 |
7 changed files with 40 additions and 27 deletions
|
@ -20,6 +20,7 @@ class OllasController extends Controller
|
|||
$pedido = $gdc->subpedidos()->firstOrCreate([
|
||||
'nombre' => 'Pedido de Ollas de ' . $gdc->nombre,
|
||||
'tipo_pedido_id' => $tipoOlla->id,
|
||||
'cantidad_ollas' => 0,
|
||||
]);
|
||||
return response()->json(new PedidoOllasResource($pedido));
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class GrupoDeCompraPedidoResource extends JsonResource
|
||||
|
@ -9,7 +10,7 @@ class GrupoDeCompraPedidoResource extends JsonResource
|
|||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request): array {
|
||||
|
|
|
@ -21,6 +21,7 @@ class CreateTipoPedidosTable extends Migration
|
|||
});
|
||||
|
||||
$hogar = TipoPedido::firstOrCreate(['nombre' => 'hogar']);
|
||||
TipoPedido::firstOrCreate(['nombre' => 'olla']);
|
||||
|
||||
Schema::table('subpedidos', function (Blueprint $table) use ($hogar) {
|
||||
$table->foreignId('tipo_pedido_id')->default($hogar->id);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
use App\Subpedido;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
@ -17,7 +16,6 @@ class CantidadOllasPedidos extends Migration
|
|||
Schema::table('subpedidos', function (Blueprint $table) {
|
||||
$table->integer('cantidad_ollas')->nullable();
|
||||
});
|
||||
Subpedido::where('tipo_pedido_id', 1)->update(['cantidad_ollas' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,5 +24,6 @@ class DatabaseSeeder extends Seeder
|
|||
$this->call(CanastaSeeder::class);
|
||||
$this->call(GrupoDeCompraSeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
$this->call(UsuarioOllasSeeder::class);
|
||||
}
|
||||
}
|
||||
|
|
34
database/seeds/UsuarioOllasSeeder.php
Normal file
34
database/seeds/UsuarioOllasSeeder.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use App\GrupoDeCompra;
|
||||
use App\User;
|
||||
use App\UserRole;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UsuarioOllasSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$barrios = GrupoDeCompra::all();
|
||||
$usersToInsert = [];
|
||||
$ollas_id = UserRole::where('nombre', 'ollas')->first()->id;
|
||||
$pedidos_id = UserRole::where('nombre', 'barrio')->first()->id;
|
||||
|
||||
foreach ($barrios as $barrio) {
|
||||
$usersToInsert[] = DatabaseSeeder::addTimestamps([
|
||||
'name' => $barrio->nombre . '_ollas',
|
||||
'password' => User::where(['grupo_de_compra_id' => $barrio->id, 'role_id' => $pedidos_id])->first()->password,
|
||||
'role_id' => $ollas_id,
|
||||
'grupo_de_compra_id' => $barrio->id,
|
||||
]);
|
||||
}
|
||||
|
||||
foreach (array_chunk($usersToInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk)
|
||||
User::insert($chunk);
|
||||
}
|
||||
}
|
25
package-lock.json
generated
25
package-lock.json
generated
|
@ -1648,19 +1648,6 @@
|
|||
"hasInstallScript": true,
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@parcel/watcher-android-arm64": "2.5.1",
|
||||
"@parcel/watcher-darwin-arm64": "2.5.1",
|
||||
"@parcel/watcher-darwin-x64": "2.5.1",
|
||||
"@parcel/watcher-freebsd-x64": "2.5.1",
|
||||
"@parcel/watcher-linux-arm-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-arm-musl": "2.5.1",
|
||||
"@parcel/watcher-linux-arm64-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-arm64-musl": "2.5.1",
|
||||
"@parcel/watcher-linux-x64-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-x64-musl": "2.5.1",
|
||||
"@parcel/watcher-win32-arm64": "2.5.1",
|
||||
"@parcel/watcher-win32-ia32": "2.5.1",
|
||||
"@parcel/watcher-win32-x64": "2.5.1",
|
||||
"detect-libc": "^1.0.3",
|
||||
"is-glob": "^4.0.3",
|
||||
"micromatch": "^4.0.5",
|
||||
|
@ -2056,7 +2043,6 @@
|
|||
"dependencies": {
|
||||
"@babel/parser": "^7.23.5",
|
||||
"postcss": "^8.4.14",
|
||||
"prettier": "^1.18.2 || ^2.0.0",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
|
@ -2102,7 +2088,6 @@
|
|||
"merge-source-map": "^1.1.0",
|
||||
"postcss": "^7.0.36",
|
||||
"postcss-selector-parser": "^6.0.2",
|
||||
"prettier": "^1.18.2 || ^2.0.0",
|
||||
"source-map": "~0.6.1",
|
||||
"vue-template-es2015-compiler": "^1.9.0"
|
||||
},
|
||||
|
@ -3555,7 +3540,6 @@
|
|||
"anymatch": "^2.0.0",
|
||||
"async-each": "^1.0.1",
|
||||
"braces": "^2.3.2",
|
||||
"fsevents": "^1.2.7",
|
||||
"glob-parent": "^3.1.0",
|
||||
"inherits": "^2.0.3",
|
||||
"is-binary-path": "^1.0.0",
|
||||
|
@ -7975,9 +7959,6 @@
|
|||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
||||
"integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
|
@ -11334,7 +11315,6 @@
|
|||
"integrity": "sha512-d0NoFH4v6SjEK7BoX810Jsrhj7IQSYHAHLi/iSpgqKc7LaIDshFRlSg5LOymf9FqQhxEHs2W5ZQXlvy0KD45Uw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@parcel/watcher": "^2.4.1",
|
||||
"chokidar": "^4.0.0",
|
||||
"immutable": "^5.0.2",
|
||||
"source-map-js": ">=0.6.2 <2.0.0"
|
||||
|
@ -13424,10 +13404,8 @@
|
|||
"integrity": "sha512-9P3MWk6SrKjHsGkLT2KHXdQ/9SNkyoJbabxnKOoJepsvJjJG8uYTR3yTPxPQvNDI3w4Nz1xnE0TLHK4RIVe/MQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"chokidar": "^3.4.1",
|
||||
"graceful-fs": "^4.1.2",
|
||||
"neo-async": "^2.5.0",
|
||||
"watchpack-chokidar2": "^2.0.1"
|
||||
"neo-async": "^2.5.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"chokidar": "^3.4.1",
|
||||
|
@ -13493,7 +13471,6 @@
|
|||
"dependencies": {
|
||||
"anymatch": "~3.1.2",
|
||||
"braces": "~3.0.2",
|
||||
"fsevents": "~2.3.2",
|
||||
"glob-parent": "~5.1.2",
|
||||
"is-binary-path": "~2.1.0",
|
||||
"is-glob": "~4.0.1",
|
||||
|
|
Loading…
Add table
Reference in a new issue