确定是否所有列都不为 null 除了一个:Laravel

Determine if all columns are not null Except one: Laravel

我有一个名为 Applications 的大型 table(30 多列)。根据填写的栏目判断申请是否完成。

如何在查询中表达以下内容?

如果所有列不为 Null,除了 Application_Status 将申请状态更新为 True。

可能的长路:

$appCheck = Application::where('a, !=, null')
->where('b', '!=', null)
->where('c', '!=', null)
->where(etc... 30 more columns..., '!=', null)
->except(['m','n','application_status'])
)->first();

if($appCheck == true){
$appCheck->update([
'application_status' => 1,
])
}

有没有一种快捷方式可以做到这一点,这样我就不必写出每一列的名称了? 浏览器...

$appCheck = Applicaiton::whereNotNull('*')->except(['m','n','application_status'])->first()

if($appCheck == true){
$appCheck->update([
'application_status' => 1,
])
}

我的想法是将数据库 table 的所有列作为一个数组,然后通过删除不需要的列来过滤它们。最后我们得到过滤后的列,我们在 `whereNotNull' 方法中使用它们:

Application::whereNotNull(
        array_values(
            array_filter(
                Schema::getColumnListing('applications'),
                fn($column) => !in_array($column, ['m', 'n', 'application_status']),
            ),
        ),
    )->first();