Here is My Controller's Code to get Order list with Condition apply in join table
$orders = Order::whereHas('order_carpets', function($q){
$q->where('carpent_no', '1345');
})->get();
Model Code looks something like this
class Order extends Model
{
protected $table = 'orders';
public function order_carpets()
{
return $this->belongsToMany(Order_carpet::class, 'orders', 'id', 'order_carpet_id');
}
public function customers()
{
return $this->belongsToMany(Customer::class, 'orders', 'id', 'customer_id');
}
}
class Order_carpet extends Model
{
public function orders()
{
return $this->hasMany(Order::class);
}
}
The result I'm getting now is all data of table Order