| 12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace App\Http\Resources;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
- class UserResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'name' => $this->name,
- 'email' => $this->email,
- 'language' => $this->language,
- 'type' => $this->type,
- 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i'),
- 'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i'),
- ];
- }
- public static function collection($resource): AnonymousResourceCollection
- {
- return parent::collection($resource);
- }
- }
|