I am trying to assign some value to a variable named $bonus in if else conditions and then I am trying to call $bonus outside of the if else condition so the true condition's variable should be called automatically. I have tried this code but it is giving me an error on debugging mode of laravel
Error:
Undefined variable: bonus
Code:
if($data->lend_amount >= 50 && $data->lend_amount <= 500)
{
$bonus = ($data->lend_amount * 4)/100;
}
else if($data->lend_amount >= 500 && $data->lend_amount <= 50000)
{
$bonus = ($data->lend_amount * 5)/100;
}
if ($user_b_update){
Transaction::create([
'user_id' => $data->user_id,
'trans_id' => rand(),
'time' => Carbon::now(),
'description' => 'Matching Bonus Of '.$bvp.' Users',
'amount' => $bonus,
'new_balance' => $newacc_bal,
'new_earning' => $newbal,
'type' => 4,
'charge' => 0
]);
Aucun commentaire:
Enregistrer un commentaire