I have a table like this:
table - field1: tinyint - field2: varchar (nullable) - datefield: timestamp (nullable)
Now I want to get all entries
Using coalesce() converts null to 0:
$query = Model::where('field1', 1) ->whereNull('field2') ->where(DB::raw('COALESCE(datefield_at,0)'), '<', $date) ;