阅读(526) (8)

Laravel 8 whereNull() {#collection-method}

2021-07-01 16:46:26 更新

whereNull 方法筛选给定键为 NULL 的项:

$collection = collect([
    ['name' => 'Desk'],
    ['name' => null],
    ['name' => 'Bookcase'],
]);

$filtered = $collection->whereNull('name');

$filtered->all();

/*
    [
        ['name' => null],
    ]
*/