Is there a way how to add two function which is the print and move the data to another table in a one button? In my project where I have table which is the accepted reservation table. Here the admin can let borrow the equipment since it is accepted reservation. So when I click the borrow button how can I print preview the row data and move that row data in borrowed item since it is now a borrowed item. Anyone can help me?
Here when I click the borrow button the print preview will display only the row data and move the row data to borroweditem table. While the quantity of that item which is in another table will be deducted by 1.
Here’s my view.blade.php
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Accepted Reservations</h6>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered tbl_acceptres display" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th hidden>Id</th>
<th>Name</th>
<th>Equipment</th>
<th>Reservation Date</th>
<th>Rooms</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach ($acc as $accdata)
<tr>
<td hidden> </td>
<td>{{ $accdata->name }} </td>
<td>{{ $accdata->Name_item }}</td>
<td>{{ $accdata->dt_item }}</td>
<td>{{ $accdata->room_item }} </td>
<td>
<form action="{{route('admin.reservation.borrow',$accdata->id)}}" method="POST">
{{ csrf_field() }}
<button type="submit" class="btn btn-primary btn-sm">Borrow <i class="fas fa-chevron-right"></i></button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
Here’s my controller
public function borrow(Request $request, $id){
$bor = Reservation::where('id', $id)->first();
$kl=$first->name;
$mn=$first->Name_item;
$op=$first->dt_item;
$qr=$first->room_item;
$bitem = new BorrowedItem();
$bitem->bname= $kl;
$bitem->bdate= $mn;
$bitem->itemb= $op;
$bitem->broom= $qr;
$bitem->save();
$bor->delete();
returned redirect()->back()->with('message','Successfully borrowed item')
}