belongsTo(Product::class); } public function users() { return $this->belongsToMany(User::class); } public function free($product_id, $user_id) { return $query->where([ ['user_id', $user_id], ['product_id', $product_id], ['usedBy', ''], ]); } }