SentResource.php 1006 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Resources;
  3. use App\Http\Api\MdRender;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. class SentResource extends JsonResource
  6. {
  7. /**
  8. * Transform the resource into an array.
  9. *
  10. * @param \Illuminate\Http\Request $request
  11. * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
  12. */
  13. public function toArray($request)
  14. {
  15. return [
  16. "content"=>$this->content,
  17. "html"=> MdRender::render($this->content,$this->channel_uid),
  18. "book"=> $this->book_id,
  19. "paragraph"=> $this->paragraph,
  20. "word_start"=> $this->word_start,
  21. "word_end"=> $this->word_end,
  22. "editor"=> \App\Http\Api\StudioApi::getById($this->editor_uid),
  23. "channel"=> [
  24. "name"=>"channel",
  25. "id"=> $this->channel_uid,
  26. ],
  27. "updated_at"=> $this->updated_at,
  28. ];
  29. }
  30. }