@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | |
38 | 38 | public function __construct($resource, $relations = []) |
39 | 39 | { |
40 | - if (!($resource instanceof Model)) |
|
41 | - throw new Exception('Object passed to the transformer resource method is not a eloquent model', 500); |
|
40 | + if (!($resource instanceof Model)) { |
|
41 | + throw new Exception('Object passed to the transformer resource method is not a eloquent model', 500); |
|
42 | + } |
|
42 | 43 | $this->resource = $resource; |
43 | 44 | $relations = is_array($relations) ? $relations : []; |
44 | 45 | parent::__construct(self::loadRelations($resource, $relations)); |
@@ -51,8 +52,9 @@ discard block |
||
51 | 52 | |
52 | 53 | public static function collection($resource, array $relations = []) |
53 | 54 | { |
54 | - if (!($resource instanceof Collection)) |
|
55 | - throw new Exception('Object passed to the transformer collection method is not a collection', 500); |
|
55 | + if (!($resource instanceof Collection)) { |
|
56 | + throw new Exception('Object passed to the transformer collection method is not a collection', 500); |
|
57 | + } |
|
56 | 58 | |
57 | 59 | $resource = self::processLimit($resource); |
58 | 60 | $resource = self::loadRelations($resource, $relations); |
@@ -67,8 +69,9 @@ discard block |
||
67 | 69 | |
68 | 70 | public function toArray($request) |
69 | 71 | { |
70 | - if (!method_exists($this, 'transformResource')) |
|
71 | - throw new \Exception("transformResource method not set on " . static::class, 500); |
|
72 | + if (!method_exists($this, 'transformResource')) { |
|
73 | + throw new \Exception("transformResource method not set on " . static::class, 500); |
|
74 | + } |
|
72 | 75 | return array_merge($this->transformResource($this->resource), $this->includeRelations()); |
73 | 76 | } |
74 | 77 | } |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $requestedLimit = $this->parseRequestLimitParameter(); |
35 | 35 | $maxLimit = $this->limit; |
36 | 36 | |
37 | - if ($maxLimit === -1) |
|
38 | - return $requestedLimit; |
|
39 | - elseif ($requestedLimit > $maxLimit) { |
|
37 | + if ($maxLimit === -1) { |
|
38 | + return $requestedLimit; |
|
39 | + } elseif ($requestedLimit > $maxLimit) { |
|
40 | 40 | return $maxLimit; |
41 | 41 | } |
42 | 42 | return $requestedLimit; |
@@ -45,8 +45,9 @@ discard block |
||
45 | 45 | private static function processLimit(Collection $resource){ |
46 | 46 | $class = static::class; |
47 | 47 | $limit = call_class_function($class,'getLimitParameter'); |
48 | - if($limit === -1) |
|
49 | - return $resource; |
|
48 | + if($limit === -1) { |
|
49 | + return $resource; |
|
50 | + } |
|
50 | 51 | return $resource->take((int) $limit); |
51 | 52 | } |
52 | 53 |