@@ 116-126 (lines=11) @@ | ||
113 | * @param null $callback |
|
114 | * @return \Illuminate\Http\JsonResponse |
|
115 | */ |
|
116 | protected function respondWithItem($item, $callback = null) |
|
117 | { |
|
118 | if ($callback) { |
|
119 | $builder = $this->withIncludes($item); |
|
120 | $item = $callback($builder); |
|
121 | } |
|
122 | ||
123 | $rootScope = $this->fractal->item($item, $this->transformer, $this->resourceKey); |
|
124 | ||
125 | return $this->respondWithArray($rootScope->toArray()); |
|
126 | } |
|
127 | ||
128 | /** |
|
129 | * Returns a json response that indicates the resource was successfully created also |
|
@@ 136-147 (lines=12) @@ | ||
133 | * @param null $callback |
|
134 | * @return \Illuminate\Http\JsonResponse |
|
135 | */ |
|
136 | protected function respondWithItemCreated($item, $callback = null) |
|
137 | { |
|
138 | if ($callback) { |
|
139 | $builder = $this->withIncludes($item); |
|
140 | $item = $callback($builder); |
|
141 | } |
|
142 | ||
143 | $this->setStatusCode(201); |
|
144 | $rootScope = $this->fractal->item($item, $this->transformer, $this->resourceKey); |
|
145 | ||
146 | return $this->respondWithArray($rootScope->toArray()); |
|
147 | } |
|
148 | ||
149 | /** |
|
150 | * Returns a json response that contains the specified collection |