Larvel – If SQL statement NULL then return Zero

Dealing with null values in Laravel database query?

Larvel – If SQL statement NULL then return Zero. You can use is_null() method.

 $dbill=DB::table('trn_transaction')->where('trn_type','Expense')->orderBy('trn_billno', 'desc')->first();
if(is_null($dbill))
{
$billno= 1;
}
else
{
$billno=$dbill->trn_billno + 1;
} 
🔥17 Views

Do you have anything to Ask?

This site uses Akismet to reduce spam. Learn how your comment data is processed.