J'ai résolu de cette façon :
$candidatformation = CandidatFormation::where('id',$candidatformation_id)
->with([
'formation' => function ($query) {
$query->where('show',1);
},
'formation.unities' => function ($query) {
$query->where('show',1);
},
'formation.unities.modules' => function ($query) {
$query->where('show',1);
},
'formation.unities.modules.lessons' => function ($query) {
$query->where('show',1);
}
])
->firstOrFail();
Il y a peut être une solution différente, mais celle ci fonctionne.