SentResource.php 1.0 KB

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