过滤器功能在 Live Servier 中不起作用

Filter Function Not Working in Live Servier

我有两个 table,一个是 categories,其中有 parent_id,另一个是 pages,其中 category id 存储在 category_id 列中。我得到 pages 其中 category parent_id0 使用 filter 方法。它在本地主机上工作正常,但在实时服务器上它不工作。

$pages = Page::with('category')->latest()->get()->filter(function($page){
            return $page->category->parent_id === 0;
         });
return view('admin.page',compact('pages'));

不对比就试试:

$pages = Page::with('category')->latest()->get()->filter(function($page){
        return $page->category->parent_id;
     });

return view('admin.page',compact('pages'));