Skip to content

Instantly share code, notes, and snippets.

@greydnls
Last active August 29, 2015 14:06
Show Gist options
  • Save greydnls/9acee8bcecea3d878379 to your computer and use it in GitHub Desktop.
Save greydnls/9acee8bcecea3d878379 to your computer and use it in GitHub Desktop.
Array
(
[query] => select *, sum((ifnull(`debit`,0) - ifnull(`credit`,0))) AS `amount`, `acct_journal_details`.*, `acct_journal`.`employee_id` from `acct_journal_details` inner join `acct_journal` on `acct_journal`.`acct_journal_id` = `acct_journal_details`.`acct_journal_id` where `is_per_diem` <> ? and `acct_journal`.`employee_id` in (?, ?, ?, ?) group by `acct_journal`.`employee_id`, `acct_journal_details`.`ref_date` having `amount` <> ?
[bindings] => Array
(
[0] => FirstWhere
[1] => Having
[2] => Relationship
[3] => Relationship
[4] => Relationship
[5] => Relationship
)
[time] => 7.63
)
// Eloquent Query
public function paidPerDiems()
{
return $this->hasManyThrough('TeamClock\Eloquent\Models\AcctJournalDetail', 'TeamClock\Eloquent\Models\AcctJournal', 'employee_id', 'acct_journal_id' )
->selectRaw('*, sum((ifnull(`debit`,0) - ifnull(`credit`,0))) AS `amount`')
->where('is_per_diem', '<>', 0)
->having('amount', '<>', '0')
->groupBy('acct_journal.employee_id', 'acct_journal_details.ref_date');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment