I'm having problems accessing the Pivot relationship.
#relations: array:1 [
"orders_material" => Collection {#250
#items: []
}
]
I want to get the orders_material that have pivot values null
This is the query :
$material = Material::with(['orders_material' => function($query) use ($begin_date, $end_date, $begin_hour, $hour_final)
{
$query->whereBetween('Orders_has_Material.date_begin',[$begin_date, $end_date])
->whereBetween('Orders_has_Material.date_final',[$begin_date, $end_date])
->where('Orders_has_Material.Material_id', null)
->where('Orders_has_Material.Orders_id', null);
}])
->get();
dd($material);
public function orders_material()
{
return $this->belongsToMany('App\Orders', 'Orders_has_Material', 'Material_id', 'Orders_id');
}