@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | return $this->model->create($data); |
49 | 49 | } |
50 | 50 | |
51 | - public function update(array $data, $id, $attribute="id") |
|
51 | + public function update(array $data, $id, $attribute = "id") |
|
52 | 52 | { |
53 | 53 | $model_data = $this->model->where($attribute, '=', $id)->first(); |
54 | 54 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | return $this; |
124 | 124 | } |
125 | 125 | |
126 | - public function skipCriteria($status = true){ |
|
126 | + public function skipCriteria($status = true) { |
|
127 | 127 | $this->skipCriteria = $status; |
128 | 128 | return $this; |
129 | 129 | } |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | public function applyCriteria() { |
146 | - if($this->skipCriteria === true) |
|
146 | + if ($this->skipCriteria === true) |
|
147 | 147 | return $this; |
148 | 148 | |
149 | - foreach($this->getCriteria() as $criteria) { |
|
150 | - if($criteria instanceof Criteria) |
|
149 | + foreach ($this->getCriteria() as $criteria) { |
|
150 | + if ($criteria instanceof Criteria) |
|
151 | 151 | $this->model = $criteria->apply($this->model, $this); |
152 | 152 | } |
153 | 153 |
@@ -29,6 +29,9 @@ discard block |
||
29 | 29 | $this->makeModel(); |
30 | 30 | } |
31 | 31 | |
32 | + /** |
|
33 | + * @return string |
|
34 | + */ |
|
32 | 35 | abstract public function model(); |
33 | 36 | |
34 | 37 | public function all($columns = ['*']) |
@@ -96,6 +99,9 @@ discard block |
||
96 | 99 | return $this->model->findOrCreate($data); |
97 | 100 | } |
98 | 101 | |
102 | + /** |
|
103 | + * @param string $attribute |
|
104 | + */ |
|
99 | 105 | public function findBy($attribute, $value, $columns = array('*')) |
100 | 106 | { |
101 | 107 | $this->applyCriteria(); |
@@ -107,8 +107,9 @@ discard block |
||
107 | 107 | $model = $this->app->make($this->model()); |
108 | 108 | //$model = app()->make($this->model()); |
109 | 109 | |
110 | - if (!$model instanceof Model) |
|
111 | - throw new RepositoryException("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model"); |
|
110 | + if (!$model instanceof Model) { |
|
111 | + throw new RepositoryException("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model"); |
|
112 | + } |
|
112 | 113 | |
113 | 114 | return $this->model = $model; |
114 | 115 | } |
@@ -143,12 +144,14 @@ discard block |
||
143 | 144 | } |
144 | 145 | |
145 | 146 | public function applyCriteria() { |
146 | - if($this->skipCriteria === true) |
|
147 | - return $this; |
|
147 | + if($this->skipCriteria === true) { |
|
148 | + return $this; |
|
149 | + } |
|
148 | 150 | |
149 | 151 | foreach($this->getCriteria() as $criteria) { |
150 | - if($criteria instanceof Criteria) |
|
151 | - $this->model = $criteria->apply($this->model, $this); |
|
152 | + if($criteria instanceof Criteria) { |
|
153 | + $this->model = $criteria->apply($this->model, $this); |
|
154 | + } |
|
152 | 155 | } |
153 | 156 | |
154 | 157 | return $this; |