1. $query->whereHas('patient', function ($q) use ($name) {
    2. $q->from('cbfy_home.patients')->where('name', 'like', "%$name%");
    3. });