Answer the question
In order to leave comments, you need to log in
How to properly use relationships in Laravel?
Good day, I ask for help from those who know. There is no way to organize the next request within eloquent
SELECT goods.colony, goods.quantity, goods_data.category, goods.goods_id
FROM goods
INNER JOIN goods_data ON goods.goods_id = goods_data.id
WHERE goods_data.category = 15 AND goods.region = 1
public function category()
{
return $this->belongsToMany('App\Models\GoodsData', 'id', 'goods_id');
}
public static function getCategoryGoods($id, $region)
{
return Goods::where('region', '=', $region)->with('category')->where('category','=', $id)->paginate(18);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question