Laravel 雄辩的关系-whereNotNull不存在
我有一段口若悬河的关系,我正试图质疑Laravel 雄辩的关系-whereNotNull不存在,laravel,eloquent,Laravel,Eloquent,我有一段口若悬河的关系,我正试图质疑 $deliveryOverride = $product->days->whereNotNull('margin') ->where('price_id', $order['price_id']) ->where('product_id', $product->id) ->where('sale_at', date('Y-m-d', strtotime($day))) ->first(); 我不断地发现这个错误 方
$deliveryOverride = $product->days->whereNotNull('margin')
->where('price_id', $order['price_id'])
->where('product_id', $product->id)
->where('sale_at', date('Y-m-d', strtotime($day)))
->first();
我不断地发现这个错误
方法whereNotNull不存在
有什么想法吗?当您直接对有说服力的对象调用关系属性时,将执行查询并返回。集合上没有
WhereNotNull
函数
如果要使用该函数查询关系,则必须直接调用关系函数。由于查询将在数据库上进行,因此这也将提高性能
$deliveryOverride = $product->days() // Call relation function here
->whereNotNull('margin')
->where('price_id', $order['price_id'])
->where('product_id', $product->id)
->where('sale_at', date('Y-m-d', strtotime($day)))
->first();
有关这方面的更多信息可以在此处的文档中找到:当您直接对一个有说服力的对象调用关系属性时,将执行查询并返回一个。集合上没有
WhereNotNull
函数
如果要使用该函数查询关系,则必须直接调用关系函数。由于查询将在数据库上进行,因此这也将提高性能
$deliveryOverride = $product->days() // Call relation function here
->whereNotNull('margin')
->where('price_id', $order['price_id'])
->where('product_id', $product->id)
->where('sale_at', date('Y-m-d', strtotime($day)))
->first();
有关这方面的更多信息,请参阅此处的文档: