Search code examples
laravellaravel-5

Check a column is empty array or not in Laravel


I have a json column which is set as null by default and casted as array in model. I've used

->where('column_name', '\[\]')->get();

It retrun empty collection.

My question is if i've to check whether a column is empty array or not in where condition what will i do?


Solution

  • thanks to this answer

    where('column_name',DB::raw("json_array()"))->get();