i have a users table i created and currently i can update the table from edit submit form with just one field (amount) but currently i want to retrieve the users details to the edit submit form so i can review them before updating all the fields
I’m using firestore and laravel, below is my controller
Thanks in advance
// my edit button below
<td><a href="{{ url('admin/edit-ref-transfer/'.$item['post_id']) }}" class="btn btn-dark">Debit</a></td>
//my route(web.php) code below
Route::get('edit-ref-transfer/{post_idz}', [AppHttpControllersAdminDashboardController::class, 'edit']);
Route::put('update-ref-transfer/{post_idz}', [AppHttpControllersAdminDashboardController::class, 'update']);
//below are my controllers DASHBORDCONTROLLER
public function edit($post_idz)
{
$key = $post_idz;
$addAmountToUserTotals = app('firebase.firestore')->database()->collection('refWithdrawlz')->document($key);
if($addAmountToUserTotals)
{
return view('admin/edit-ref-transfer',compact('addAmountToUserTotals','key'));
} else
{
return view('admin/ref-transfer')->with('status','error');
}
}
public function update(Request $request, $post_idz)
{
$datetime = Carbon::now()->toDateTimeString();
$cur_date = Carbon::createFromFormat('Y-m-d H:i:s', $datetime)->format('d-m-Y');
$addAmountToUserTotalszz = app('firebase.firestore')->database()->collection('refWithdrawlz')->document($post_idz);
$addAmountToUserTotalszz->update([
['path' => 'amountToPay', 'value' => ((int)$request->amountToPay)],
['path' => 'debitedAmount', 'value' => ((int)$request->amountToPay)],
['path' => 'status', 'value' => ('Debited')],
['path' => 'debitedDate', 'value' => ($cur_date)],
]);
if($addAmountToUserTotalszz)
{
return redirect('admin/ref-transfer')->with('status','Referral point debited successfully');
} else
{
return redirect('admin/ref-transfer')->with('status','Referral point not successfully debited, please try again ');
}
}
i want to be able to edit users email and other fields and would like to retrieve them then update. i will be glad to get help thanks