Select statement set null column defualt value to 0
Hi,
I am creating a query and executing it in sqlserver. I want to set null column value to 0 in select statement using method like coalesce, isnull but it is throwing error.
"can not access empty property".
So, you can add an attribute mutator in the model if all you're looking to do is return zero instead of null. Not sure if this is a solution in your case but here's how you'd do it
public function getYourColumnNameAttribute($value){
return $value !== null ? $value : 0;
}