Laravel 不应静态调用非静态方法Illumb\Database\Eloquent\Model::newQuery()

Laravel 不应静态调用非静态方法Illumb\Database\Eloquent\Model::newQuery(),laravel,Laravel,接收每当我运行以下代码时发生的错误(标题中): SearchController.php public function index(Request $request) { $distances = DB::table('posts')->select('distance')->distinct()->get()->pluck('distance'); $prices = DB::table('posts')->select('price')-&g

接收每当我运行以下代码时发生的错误(标题中):

SearchController.php

public function index(Request $request)
   {
   $distances = DB::table('posts')->select('distance')->distinct()->get()->pluck('distance');
   $prices = DB::table('posts')->select('price')->distinct()->get()->pluck('price');

   $post = Post::newQuery();

    if ($request->has('price')) {
    $post->where('price', $request->price);
    }

  if ($request->has('distance')) {
   $post->where('distance', $request->distance);
   }

   return view('Pages.search', [
    'distances' => $distances,
    'prices' => $prices,
    'posts' => $post->get()
   ]);
使用

query()


它应该使用
$post=post::query()
;以前没有见过
newQuery()
方法。太棒了,所以我已经这样做了,现在我按submit,没有显示任何内容,功能也不起作用。如果有帮助,请将此答案标记为已验证you@codingkidplease更改提交事件。
 $post = Post::query();