Обычно вы проверяете значение NULL с помощью:
Код: Выделить всё
->whereNull("column")
Код: Выделить всё
->where("column",value)
Код: Выделить всё
// app/Models/YourModel.php
public function scopeWhereXIs($query, $search_value)
{
//if $search_value is NULL, use whereNull
if ($search_value === null) {
return $query->whereNull('x');
}
//otherwise use where clause
return $query->where('x', $search_value);
}
Код: Выделить всё
->whereXIs($search_value_from_request)
Что вы думаете? Какова была бы наилучшая практика?
Привет
Подробнее здесь: https://stackoverflow.com/questions/798 ... ld-be-null
Мобильная версия