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; }