@@ -248,14 +248,16 @@ discard block |
||
248 | 248 | public function find($entityId = 0, $columns = ['*']) |
249 | 249 | { |
250 | 250 | if ($this->allowCaching) { |
251 | - if (isset($this->cache[$entityId])) |
|
252 | - return $this->cache[$entityId]; |
|
251 | + if (isset($this->cache[$entityId])) { |
|
252 | + return $this->cache[$entityId]; |
|
253 | + } |
|
253 | 254 | } |
254 | 255 | |
255 | 256 | $entity = $this->model->with($this->with)->find($entityId, $columns); |
256 | 257 | |
257 | - if ($this->allowCaching) |
|
258 | - $this->cache[$entityId] = $entity; |
|
258 | + if ($this->allowCaching) { |
|
259 | + $this->cache[$entityId] = $entity; |
|
260 | + } |
|
259 | 261 | |
260 | 262 | return $entity; |
261 | 263 | } |
@@ -271,14 +273,16 @@ discard block |
||
271 | 273 | public function findOrFail($entityId = 0, $columns = ['*']) |
272 | 274 | { |
273 | 275 | if ($this->allowCaching) { |
274 | - if (isset($this->cache[$entityId])) |
|
275 | - return $this->cache[$entityId]; |
|
276 | + if (isset($this->cache[$entityId])) { |
|
277 | + return $this->cache[$entityId]; |
|
278 | + } |
|
276 | 279 | } |
277 | 280 | |
278 | 281 | $entity = $this->model->with($this->with)->findOrFail($entityId, $columns); |
279 | 282 | |
280 | - if ($this->allowCaching) |
|
281 | - $this->cache[$entityId] = $entity; |
|
283 | + if ($this->allowCaching) { |
|
284 | + $this->cache[$entityId] = $entity; |
|
285 | + } |
|
282 | 286 | |
283 | 287 | return $entity; |
284 | 288 | } |
@@ -292,14 +296,16 @@ discard block |
||
292 | 296 | public function first($filter = [], $columns = ['*']) |
293 | 297 | { |
294 | 298 | if ($this->allowCaching) { |
295 | - if (isset($this->cache['first'])) |
|
296 | - return $this->cache['first']; |
|
299 | + if (isset($this->cache['first'])) { |
|
300 | + return $this->cache['first']; |
|
301 | + } |
|
297 | 302 | } |
298 | 303 | |
299 | 304 | $entity = $this->filter($filter)->with($this->with)->select($columns)->first(); |
300 | 305 | |
301 | - if ($this->allowCaching) |
|
302 | - $this->cache['first'] = $entity; |
|
306 | + if ($this->allowCaching) { |
|
307 | + $this->cache['first'] = $entity; |
|
308 | + } |
|
303 | 309 | |
304 | 310 | return $entity; |
305 | 311 | } |
@@ -313,14 +319,16 @@ discard block |
||
313 | 319 | public function last($filter = [], $columns = ['*']) |
314 | 320 | { |
315 | 321 | if ($this->allowCaching) { |
316 | - if (isset($this->cache['last'])) |
|
317 | - return $this->cache['last']; |
|
322 | + if (isset($this->cache['last'])) { |
|
323 | + return $this->cache['last']; |
|
324 | + } |
|
318 | 325 | } |
319 | 326 | |
320 | 327 | $entity = $this->filter($filter)->with($this->with)->select($columns)->orderBy('id', 'desc')->first(); |
321 | 328 | |
322 | - if ($this->allowCaching) |
|
323 | - $this->cache['last'] = $entity; |
|
329 | + if ($this->allowCaching) { |
|
330 | + $this->cache['last'] = $entity; |
|
331 | + } |
|
324 | 332 | |
325 | 333 | return $entity; |
326 | 334 | } |