| @@ 7-28 (lines=22) @@ | ||
| 4 | ||
| 5 | use Illuminate\Http\Resources\Json\JsonResource; |
|
| 6 | ||
| 7 | class DummyResource extends JsonResource |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Transform the resource into an array. |
|
| 11 | * |
|
| 12 | * @param Request $request |
|
| 13 | * @return array |
|
| 14 | */ |
|
| 15 | public function toArray($request) |
|
| 16 | { |
|
| 17 | if (! $this->resource) { |
|
| 18 | return []; |
|
| 19 | } |
|
| 20 | ||
| 21 | return [ |
|
| 22 | 'id' => $this->id, |
|
| 23 | // Add attributes here |
|
| 24 | 'created_at' => $this->created_at, |
|
| 25 | 'updated_at' => $this->updated_at, |
|
| 26 | ]; |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||
| @@ 7-28 (lines=22) @@ | ||
| 4 | ||
| 5 | use Illuminate\Http\Resources\Json\JsonResource; |
|
| 6 | ||
| 7 | class Role extends JsonResource |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Transform the resource into an array. |
|
| 11 | * |
|
| 12 | * @param Request $request |
|
| 13 | * @return array |
|
| 14 | */ |
|
| 15 | public function toArray($request) |
|
| 16 | { |
|
| 17 | if (! $this->resource) { |
|
| 18 | return []; |
|
| 19 | } |
|
| 20 | ||
| 21 | return [ |
|
| 22 | 'id' => $this->id, |
|
| 23 | // Add attributes here |
|
| 24 | 'created_at' => $this->created_at, |
|
| 25 | 'updated_at' => $this->updated_at, |
|
| 26 | ]; |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||