Skip to content

Instantly share code, notes, and snippets.

@iRynoh
Created September 10, 2020 00:28
Show Gist options
  • Save iRynoh/6ec63bb8e207d5e468c8d04353843d01 to your computer and use it in GitHub Desktop.
Save iRynoh/6ec63bb8e207d5e468c8d04353843d01 to your computer and use it in GitHub Desktop.
<?php
FormAccount::whereIdSource(2)
->whereIdAccount(215)
->addSelect([
'emails_sent_today' => function ($query) {
$query
->select(DB::raw('COUNT(*)'))
->from('emails as outbound')
->where('outbound.id_form_account', DB::raw('form_accounts.id'))
->where('outbound.id_source',DB::raw('form_accounts.id_source'))
->whereDate('outbound.created_at', now())
->where('outbound.id_type_direction', 1)
->where('outbound.id_type_communication', 1)
->groupBy('id_form_account');
},
])
->orderBy('emails_sent_today', 'desc')
->first();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment