select *, (select count(*) from product_country where product_country.product_id = products.id and product_country.country_id in (1,2)) from products;
select * from products where (select count(*) from product_country where product_country.product_id = products.id and product_country.country_id in (1,2)) = 2;
select count(*), product_id, group_concat(country_id) from product_country where product_country.product_id in (1,3) group by product_id;
select * from products;
select * from products where exists(select 1 product_country from product_country, country where product_country.product_id = products.id and product_country.country_id = country.id);
select * from products where exists(select 1 product_country from product_country where product_country.product_id = products.id and product_country.country_id = 3);
select * from products where (select count(*) from product_country where product_country.product_id = products.id and product_country.country_id in (1,2)) == 2;
public function user()
{
$instance = $this->newRelatedInstance(User::class);
$foreignKey = 'requests.id';
$localKey = 'request_id';
return $this->newHasOne($instance->newQuery(), $this, $foreignKey, $localKey)->join('orders.requests', 'requests.user_id', '=', 'users.id');
}