where('id', $value) ->whereExists(function ($query) { $query->select(DB::raw(1)) ->from('sigtap.procedimento_cid') ->whereColumn('sigtap.procedimento_cid.procedimento_id', 'sigtap.procedimento.id') ->where('principal', 'S'); })->exists(); } public function message() { return "Procedimento exige CID."; } }