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

200
Vistas
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
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