when($typeEmissionReduction, function ($q) use ($typeEmissionReduction) { $q->where('type', $typeEmissionReduction); }) ->first(); } public function findAllByMitigation(string $mitigationId) { return EmissionReductionMitigation::where('mitigation_id', $mitigationId)->get(); } }