public static function generateSelectedWinnerBid(Get $get, Set $set)
{
$purchaseId = $get('id'); // Assuming the form has the purchase ID
$purchase = Purchase::find($purchaseId);
if ($purchase) {
$quote = $purchase->quotes()->where('has_confirmed', true)->orderBy('id', 'desc')->first();
if ($quote) {
$set('awarded_company', $quote->company_name);
$set('amount', $quote->amount);
$set('amount_letters', self::convertNumberToWords($quote->amount));
// dd('Form Values Set:', [
// 'awarded_company' => $quote->company_name,
// 'amount' => $quote->amount,
// 'amount_letters' => self::convertNumberToWords($quote->amount),
// ]); // Debug: Check form values set
Notification::make()
->title('Form fields have been populated successfully.')
->success()
->send();
} else {
Notification::make()
->title('No confirmed quote found for this purchase.')
->danger()
->send();
}
} else {
Notification::make()
->title('Purchase not found.')
->danger()
->send();
}
}
public static function generateSelectedWinnerBid(Get $get, Set $set)
{
$purchaseId = $get('id'); // Assuming the form has the purchase ID
$purchase = Purchase::find($purchaseId);
if ($purchase) {
$quote = $purchase->quotes()->where('has_confirmed', true)->orderBy('id', 'desc')->first();
if ($quote) {
$set('awarded_company', $quote->company_name);
$set('amount', $quote->amount);
$set('amount_letters', self::convertNumberToWords($quote->amount));
// dd('Form Values Set:', [
// 'awarded_company' => $quote->company_name,
// 'amount' => $quote->amount,
// 'amount_letters' => self::convertNumberToWords($quote->amount),
// ]); // Debug: Check form values set
Notification::make()
->title('Form fields have been populated successfully.')
->success()
->send();
} else {
Notification::make()
->title('No confirmed quote found for this purchase.')
->danger()
->send();
}
} else {
Notification::make()
->title('Purchase not found.')
->danger()
->send();
}
}