@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | return explode(',', $request->include); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return []; |
|
| 29 | + return [ ]; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | public function compileRelations() |
| 36 | 36 | { |
| 37 | 37 | $requestedRelations = $this->parseRequestIncludeParameter(); |
| 38 | - $relations = []; |
|
| 38 | + $relations = [ ]; |
|
| 39 | 39 | foreach ($requestedRelations as $requestedRelation) { |
| 40 | - if (isset($this->available[$requestedRelation])) { |
|
| 41 | - $relations[$requestedRelation] = $this->available[$requestedRelation]; |
|
| 40 | + if (isset($this->available[ $requestedRelation ])) { |
|
| 41 | + $relations[ $requestedRelation ] = $this->available[ $requestedRelation ]; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | $merge = array_merge($this->include, $relations); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | if (is_array($relation)) { |
| 57 | 57 | $this->include = array_merge($this->include, $relation); |
| 58 | 58 | } else { |
| 59 | - $this->include[] = $relation; |
|
| 59 | + $this->include[ ] = $relation; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | return $this; |
@@ -64,18 +64,18 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | protected function includeRelations() |
| 66 | 66 | { |
| 67 | - $relations = []; |
|
| 67 | + $relations = [ ]; |
|
| 68 | 68 | if ($this->resource instanceof Model) { |
| 69 | 69 | $relations = $this->compileRelations(); |
| 70 | 70 | foreach ($relations as $relation => $transformer) { |
| 71 | 71 | $relationMethodName = 'transform'.ucfirst(strtolower($relation)); |
| 72 | 72 | if (method_exists($this, $relationMethodName)) { |
| 73 | - $relations[$relation] = $this->$relationMethodName($this->resource->$relation); |
|
| 73 | + $relations[ $relation ] = $this->$relationMethodName($this->resource->$relation); |
|
| 74 | 74 | } else { |
| 75 | 75 | if ($this->resource->$relation instanceof Model) { |
| 76 | - $relations[$relation] = $transformer::resource($this->whenLoaded($relation)); |
|
| 76 | + $relations[ $relation ] = $transformer::resource($this->whenLoaded($relation)); |
|
| 77 | 77 | } elseif ($this->resource->$relation instanceof Collection) { |
| 78 | - $relations[$relation] = $transformer::collection($this->whenLoaded($relation)); |
|
| 78 | + $relations[ $relation ] = $transformer::collection($this->whenLoaded($relation)); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -30,28 +30,28 @@ |
||
| 30 | 30 | { |
| 31 | 31 | use IncludesRelations, HandlesLimit; |
| 32 | 32 | |
| 33 | - public $include = []; |
|
| 33 | + public $include = [ ]; |
|
| 34 | 34 | |
| 35 | - public $available = []; |
|
| 35 | + public $available = [ ]; |
|
| 36 | 36 | |
| 37 | 37 | public $limit = -1; |
| 38 | 38 | |
| 39 | - public function __construct($resource, $relations = []) |
|
| 39 | + public function __construct($resource, $relations = [ ]) |
|
| 40 | 40 | { |
| 41 | 41 | if (!($resource instanceof Model)) { |
| 42 | 42 | throw new Exception('Object passed to the transformer resource method is not a eloquent model', 500); |
| 43 | 43 | } |
| 44 | 44 | $this->resource = $resource; |
| 45 | - $relations = is_array($relations) ? $relations : []; |
|
| 45 | + $relations = is_array($relations) ? $relations : [ ]; |
|
| 46 | 46 | parent::__construct(self::loadRelations($resource, $relations)); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public static function resource($model, array $relations = []): self |
|
| 49 | + public static function resource($model, array $relations = [ ]): self |
|
| 50 | 50 | { |
| 51 | 51 | return new static($model, $relations); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public static function collection($resource, array $relations = []) |
|
| 54 | + public static function collection($resource, array $relations = [ ]) |
|
| 55 | 55 | { |
| 56 | 56 | if (!($resource instanceof Collection)) { |
| 57 | 57 | throw new Exception('Object passed to the transformer collection method is not a collection', 500); |