Agregado tipo_id a store subpedido
This commit is contained in:
parent
b68d22380e
commit
06d80eed5a
3 changed files with 18 additions and 8 deletions
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Producto;
|
use App\Producto;
|
||||||
|
use App\TipoPedido;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Filtros\FiltroDeSubpedido;
|
use App\Filtros\FiltroDeSubpedido;
|
||||||
use App\Subpedido;
|
use App\Subpedido;
|
||||||
|
@ -28,12 +29,19 @@ class SubpedidoController extends Controller
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$validado = $this->validateSubpedido();
|
$validado = $this->validateSubpedido();
|
||||||
if (Subpedido::where("nombre",$validado["nombre"])->where("grupo_de_compra_id",$validado["grupo_de_compra_id"])->get()->count()) {
|
|
||||||
|
if (Subpedido::where("nombre", $validado["nombre"])
|
||||||
|
->where("grupo_de_compra_id", $validado["grupo_de_compra_id"])
|
||||||
|
->get()
|
||||||
|
->count()
|
||||||
|
) {
|
||||||
throw new HttpException(400, "Ya existe un subpedido con este nombre");
|
throw new HttpException(400, "Ya existe un subpedido con este nombre");
|
||||||
}
|
}
|
||||||
|
|
||||||
$s = new Subpedido();
|
$s = new Subpedido();
|
||||||
$s->nombre = $validado["nombre"];
|
$s->nombre = $validado["nombre"];
|
||||||
$s->grupo_de_compra_id = $validado["grupo_de_compra_id"];
|
$s->grupo_de_compra_id = $validado["grupo_de_compra_id"];
|
||||||
|
$s->tipo_pedido_id = $validado["tipo_id"];
|
||||||
$s->save();
|
$s->save();
|
||||||
return $this->show($s);
|
return $this->show($s);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +53,11 @@ class SubpedidoController extends Controller
|
||||||
'grupo_de_compra_id' => [
|
'grupo_de_compra_id' => [
|
||||||
'required',
|
'required',
|
||||||
Rule::in(GrupoDeCompra::all()->pluck('id')),
|
Rule::in(GrupoDeCompra::all()->pluck('id')),
|
||||||
]
|
],
|
||||||
|
'tipo_id' => [
|
||||||
|
'required',
|
||||||
|
Rule::in(TipoPedido::all()->pluck('id')),
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,8 @@ export default {
|
||||||
else
|
else
|
||||||
await this.crearPedido({
|
await this.crearPedido({
|
||||||
nombre: this.searchString,
|
nombre: this.searchString,
|
||||||
grupo_de_compra_id: this.grupo_de_compra.id
|
grupo_de_compra_id: this.grupo_de_compra.id,
|
||||||
|
tipo_id: 1,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
7
resources/js/store/modules/pedido.js
vendored
7
resources/js/store/modules/pedido.js
vendored
|
@ -55,11 +55,8 @@ const actions = {
|
||||||
async guardarSesion(_, { pedido_id }) {
|
async guardarSesion(_, { pedido_id }) {
|
||||||
await axios.post("/pedido/sesion", { id: pedido_id });
|
await axios.post("/pedido/sesion", { id: pedido_id });
|
||||||
},
|
},
|
||||||
async crearPedido({ commit, dispatch }, { nombre, grupo_de_compra_id }) {
|
async crearPedido({ commit, dispatch }, req) {
|
||||||
const response = await axios.post("/api/subpedidos", {
|
const response = await axios.post("/api/subpedidos", req);
|
||||||
nombre: nombre,
|
|
||||||
grupo_de_compra_id: grupo_de_compra_id
|
|
||||||
});
|
|
||||||
dispatch("guardarSesion", { pedido_id: response.data.data.id});
|
dispatch("guardarSesion", { pedido_id: response.data.data.id});
|
||||||
commit('setPedido', response.data.data);
|
commit('setPedido', response.data.data);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue