Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda