TipitakaChannelResource.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Http\Resources\V3;
  3. use App\Models\Channel;
  4. use Illuminate\Http\Request;
  5. /**
  6. * 有译文的公开 channel:channel 本身 + `chapter_count`(完成度过门槛的章节数)。
  7. *
  8. * @mixin Channel
  9. */
  10. class TipitakaChannelResource extends ChannelResource
  11. {
  12. /**
  13. * @param Request $request
  14. * @return array{
  15. * id: string,
  16. * name: string,
  17. * summary: string|null,
  18. * type: string,
  19. * lang: string,
  20. * status: int,
  21. * is_system: bool,
  22. * source_type: string,
  23. * source_id: string|null,
  24. * owner: array{kind: string, id: string, nickName: string, realName: string, avatar: string|null},
  25. * abilities: array{read: bool, write: bool, update: bool, delete: bool},
  26. * chapter_count: int,
  27. * created_at: string,
  28. * updated_at: string
  29. * }
  30. */
  31. public function toArray($request): array
  32. {
  33. return parent::toArray($request) + ['chapter_count' => (int) $this->getAttribute('chapter_count')];
  34. }
  35. }