I was trying to update/change the currentStatus of a row from 0 to 1 using the Approve button in the datatable, but I have no idea how to do it. Can anyone please help me?
This is how I store
public function store(Request $request){
$currentStatus = 0;
$data = $request->validate([
'to' => 'required',
'date' => 'date',
'address' => 'required',
'reference' => 'required',
'attention' => 'required',
'area' => 'required',
'project' => 'required',
'salesman' => 'required',
'location' => 'required'
]);
\App\Contract::create($data + ['status' => $currentStatus]);
return redirect('contracts/pendings');
}
This is how I display in the datatables
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Customers Name</th>
<th>Date Created</th>
<th>Project Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr>
@forelse($pendingContracts as $pendingContract)
<td>{{$pendingContract->to}}</td>
<td>{{$pendingContract->date}}</td>
<td>{{$pendingContract->project}}</td>
<td>
<button type="button" class="btn btn-info">
<a href="/contracts/pendings/{{$pendingContract->id}}" style="color: #ffffff;">View Details</a>
</button>
<button type="button" class="btn btn-success">
<a href="" style="color: #ffffff;">Approve</a>
</button>
</td>
</tr>
@empty
<center><p>no data</p></center>
@endforelse
</tbody>
</table>
