/**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $material = new Material();
     $material->fill($request->all());
     $material->save();
     return redirect()->route('materials.show', $material);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $material = new Material();
     $material->name = $request->input('name');
     $material->unit_cost = $request->input('unit_cost');
     $material->unit_id = $request->input('unit_id');
     $material->save();
     return response()->json(['newId' => $material->id]);
 }
 public function postRegistrar(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required|max:70', 'precio_compra' => 'required|numeric', 'precio_venta' => 'required|numeric', 'moneda' => 'required|boolean', 'familia_id' => 'required|integer', 'marca_id' => 'required|integer', 'unidad_entrega_id' => 'required|integer', 'stock_min' => 'required|numeric']);
     if ($validator->fails()) {
         return redirect('materiales')->withInput()->withErrors($validator);
     }
     $material = new Material();
     $material->name = $request->name;
     $material->descripcion = $request->descripcion;
     $material->precio_compra = $request->precio_compra;
     $material->precio_venta = $request->precio_venta;
     $material->moneda = $request->moneda;
     $material->familia_id = $request->familia_id;
     $material->marca_id = $request->marca_id;
     $material->unidad_entrega_id = $request->unidad_entrega_id;
     $material->stock_min = $request->stock_min;
     $material->save();
     return redirect('materiales');
 }