AuthResource.php 668 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. class AuthResource extends JsonResource
  6. {
  7. /**
  8. * Transform the resource into an array.
  9. *
  10. * @return array<string, mixed>
  11. */
  12. public function toArray(Request $request): array
  13. {
  14. return [
  15. 'access_token' => $this['access_token'],
  16. 'refresh_token' => $this['refresh_token'],
  17. 'token_type' => 'Bearer',
  18. 'expires_in' => 900, // 15 minutes
  19. 'refresh_token_expires_in' => 2592000, // 30 days
  20. 'user' => new UserResource($this['user']),
  21. ];
  22. }
  23. }