Fixed some tests.

This commit is contained in:
James Cole
2015-05-08 07:27:29 +02:00
parent cc01592085
commit cefbbcd1df
4 changed files with 153 additions and 6 deletions

View File

@@ -60,6 +60,31 @@ class Account extends Model
}
/**
* @param array $fields
*
* @return Account|null
*/
public static function firstOrNullEncrypted(array $fields)
{
// everything but the name:
$query = Account::orderBy('id');
foreach ($fields as $name => $value) {
if ($name != 'name') {
$query->where($name, $value);
}
}
$set = $query->get(['accounts.*']);
/** @var Account $account */
foreach ($set as $account) {
if ($account->name == $fields['name']) {
return $account;
}
}
return null;
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/