related query questions about laravel multiple conditions:
Table order
Order Form:
id
Self-Increment ID
order_id
Order number
paid_date
Payment Time
Table order_product
Order Product table:
Table relationships:
Order-1:n-order_product
Demand:
The following native SQL is implemented through the Laravel eloquent ORM:
SELECT * FROM order as A inner joins order_product as B on a.order_id=b.fk_order_id where (a.paid_date between ' 2016-01-01 ' and ' 2016-09-01 ') and b.product_name like '%apple iphone% '
Manual read several times, try to do, but at present only through the Wherehas realization b.product_name like this part of the condition, when the two tables all exist conditions, it is not done.
Hope Laravel predecessors, thank you!
PS. Supplement:
Currently, there are paginate requirements for filtering and retrieving the list page.
Workaround:
Class Order extends model{public function scopeproducts ($query) { return $query->join (' Order_ Product ', function ($join) { $join->on (' order.order_id ', ' = ', ' order_product.fk_order_id ');}}
Order::p roducts ()->where (...);
The above is about laravel multiple conditions of the related query problem content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!
Related articles:
Laravel Associated queries get only part of the data for a management object
Laravel Associated Query problems
Laravel Associated query articles and article authors