Closed #40 [skip ci]

This commit is contained in:
James Cole 2015-01-24 06:56:02 +01:00
parent 4bd79c880c
commit 2fbf837354

View File

@ -164,14 +164,16 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
->whereIn( ->whereIn(
'account_id', function (QueryBuilder $query) use ($model) { 'account_id', function (QueryBuilder $query) use ($model) {
$query $query
->select('id')->from('accounts') ->select('accounts.id')
->from('accounts')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->where( ->where(
function (QueryBuilder $q) use ($model) { function (QueryBuilder $q) use ($model) {
$q->where('id', $model->id); $q->where('id', $model->id);
$q->orWhere( $q->orWhere(
function (QueryBuilder $q) use ($model) { function (QueryBuilder $q) use ($model) {
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%'); $q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
$q->where('accounts.account_type_id', 3); $q->where('account_types.type', 'Initial balance account');
$q->where('accounts.active', 0); $q->where('accounts.active', 0);
} }
); );
@ -194,13 +196,15 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
\Transaction::whereIn('id', $transactions)->delete(); \Transaction::whereIn('id', $transactions)->delete();
} }
\Event::fire('account.destroy', [$model]); \Event::fire('account.destroy', [$model]);
\Account::where( \Account::
leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->where(
function (EloquentBuilder $q) use ($model) { function (EloquentBuilder $q) use ($model) {
$q->where('id', $model->id); $q->where('id', $model->id);
$q->orWhere( $q->orWhere(
function (EloquentBuilder $q) use ($model) { function (EloquentBuilder $q) use ($model) {
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%'); $q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
$q->where('accounts.account_type_id', 3); $q->where('account_types.type', 'Initial balance account');
$q->where('accounts.active', 0); $q->where('accounts.active', 0);
} }
); );