Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

105
Vistas
want to take only one input between 2 input field from html form

I have 2 input in html form. stock in and stock out. In form submission it send st_in and st_out to server with request. I want- *if two value(stock_in + stock_out) is submitted system should through error. *If no value submitted(stock_in + stock_out) system should through error. *Either "stock in" or "stock out" value should submit then the save method will store the data.

 public function stock_record(Request $request){
        $stock=new Transection;
        $stock->in=$request->st_in;
        $stock->out=$request->st_out;
        $stock->product_id=$request->st_name;
        $stock->barcode=$request->barcode;
        $stock->description=$request->st_description;
        $stock->user_id=Auth::id();
        $stock->save();
        return redirect('dashboard')->with('message',"Transection successfully updated");
    }

enter image description here

enter image description here

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

public function stock_record(Request $request){

if($request->st_in == null && $request->st_out == null)
{ 
return back()->withError('Error ...');
}

if($request->has('st_in') && $request->has('st_out'))
{
return back()->withError('Error ...');
} else if($request->has('st_in') || $request->has('st_out))
{
        $stock=new Transection;
        $stock->in=$request->st_in ?? null;
        $stock->out=$request->st_out ?? null;
        $stock->product_id=$request->st_name;
        $stock->barcode=$request->barcode;
        $stock->description=$request->st_description;
        $stock->user_id=Auth::id();
        $stock->save();
        return redirect('dashboard')->with('message',"Transection successfully updated");
    }
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

It's working Now

public function stock_record(Request $request) {

    if ($request->st_in == null && $request->st_out == null) {

       return back()->with('message', "you didn't either fill stock in or out");
    }

//correction Here if ($request->st_in > 0 && $request->st_out > 0) { return back()->with('message', "Error, You cannot fill both stock in and out at a time") //

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda