mercredi 13 novembre 2019

Join multiple variable query in single variable query in laravel

here is my sql query.
    i am trying to join three diffrent variable in single variable. which will join in a single query. 

$rData['ReportSent'] =  self::select(DB::raw('count(resident_emails.id) as ReportSent'), "residents.id as resident_id", "resident_emails.id")
            ->join("resident_emails","resident_emails.resident_id","=","residents.id")
            ->whereBetween('resident_emails.created_at', array($start, $end))
            ->where('residents.community_id', $communityId)
            ->where('residents.care_level', 'LIKE', '%'.$carelevel.'%')
            ->where('resident_emails.mail_type', 'Wellness Profile')
            ->groupBy('resident_emails.resident_id')
            ->get()->toArray();

$rData['ReportWithPhotoSent'] =  self::select(DB::raw('count(resident_emails.id) as ReportWithPhotoSent'), "residents.id as resident_id", "resident_emails.id")
            ->join("resident_emails","resident_emails.resident_id","=","residents.id")
            ->whereBetween('resident_emails.created_at', array($start, $end))
            ->where('residents.community_id', $communityId)
            ->where('residents.care_level', 'LIKE', '%'.$carelevel.'%')
            ->where('resident_emails.mail_type', 'Wellness Profile and Photos')
            ->groupBy('resident_emails.resident_id')
            ->get()->toArray();

 $rData['MessageSent'] =  self::select(DB::raw('count(resident_emails.id) as MessageSent'), "residents.id as resident_id", "resident_emails.id")
            ->join("resident_emails","resident_emails.resident_id","=","residents.id")
            ->whereBetween('resident_emails.created_at', array($start, $end))
            ->where('residents.community_id', $communityId)
            ->where('residents.care_level', 'LIKE', '%'.$carelevel.'%')
            ->where('resident_emails.mail_type', 'Message')
            ->groupBy('resident_emails.resident_id')
            ->get()->toArray();
i want this in single query on single variable.

i am trying to join three diffrent variable in single variable. which will join in a single query. i am trying to join three diffrent variable in single variable. which will join in a single query. i am trying to join three diffrent variable in single variable. which will join in a single query. i am trying to join three diffrent variable in single variable. which will join in a single query.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire