public function guardarIngrediente(Request $request)
 {
     $ingrediente = new Ingrediente();
     $ingrediente->nombre = $request->nombre;
     $ingrediente->save();
     return redirect('nuevoingrediente');
 }
Exemplo n.º 2
0
 public function postRegistraringrediente(Request $request)
 {
     $this->validate($request, ['nombre' => 'required|unique:ingredientes,nombre|min:01|max:70', 'idcategoriaingrediente' => 'exists:categoriasingredientes,id']);
     try {
         $Ingrediente = new Ingrediente();
         $Ingrediente->nombre = $request->get('nombre');
         $Ingrediente->idcategoriaingrediente = $request->get('idcategoriaingrediente');
         $Ingrediente->save();
         return array("Msg" => "Registro Exitoso", "Codigo" => "01", "Bandera" => true);
     } catch (Exception $e) {
         return array("Msg" => $e->getMessage(), "Codigo" => $e->getCode(), "Bandera" => false);
     }
 }