From 830963d59fb975ca2c7dc7093bc6c7a43f062d87 Mon Sep 17 00:00:00 2001 From: Shea Lewis Date: Mon, 19 Sep 2016 16:13:36 -0700 Subject: [PATCH] Find where method --- src/Repositories/EloquentRepository.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Repositories/EloquentRepository.php b/src/Repositories/EloquentRepository.php index ab38800..de3797b 100644 --- a/src/Repositories/EloquentRepository.php +++ b/src/Repositories/EloquentRepository.php @@ -72,16 +72,19 @@ public function findWhere($where, $columns = ['*'], $with = []) $cacheKey = $this->generateKey([$where, $columns, $with]); return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function() use ($where, $columns, $with) { + $model = $this->model->query(); + foreach ($where as $attribute => $value) { if (is_array($value)) { list($attribute, $condition, $value) = $value; - $this->model->where($attribute, $condition, $value); + + $model->where($attribute, $condition, $value); } else { - $this->model->where($attribute, '=', $value); + $model->where($attribute, '=', $value); } } - return $this->model->with($with) + return $model->with($with) ->get($columns); }); }