Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!