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