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

190
Views
How to subtract quantity from the equipment table when there's a new borrow transaction made?

I'm a Laravel newbie and I recently started working on a equipment management system whereby the admin adds quantity stock one each equipment to the system and when admin let the user borrow the equipment it deducts the quantity that the user wants from the equipment stock table. My only challenge is how to make the system to subtract quantity that the borrower wants from the equipment stock table?

Here's my controller for the button "borrow" So when I click the borrow button it will deducts the ('quantity_item') to the equipment stock table ('e_quantity')

public function borrow($id){
   $first = Reservation::where('id', $id)->first();

    $kl = $first->name;
    $mn = $first->Name_item;
    $st = $first->quantity_item; //this is the quantity that the borrower wants
    $op = $first->dt_item;
    $qr = $first->room_item;
    $first->delete();

   $second = new BorrowedItems();

    $second->bname = $kl;
    $second->bdate = $mn;
    $second->itemb = $op;
    $second->bquantity = $st;
    $second->broom = $qr;
    $second->save();

    return redirect()->back()->with('message','Item Borrowed Successfully!');
}

This is my Equipment Stock Table enter image description here

This is my BorrowedItem Table enter image description here so when I click the borrow button the data from reservationtable will transfer here

This is my Reservation Table enter image description here

enter image description here enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
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!