NavCSParaResource.php 702 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Http\Resources;
  3. use App\Models\PaliText;
  4. use Illuminate\Contracts\Support\Arrayable;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Http\Resources\Json\JsonResource;
  7. class NavCSParaResource extends JsonResource
  8. {
  9. /**
  10. * Transform the resource into an array.
  11. *
  12. * @param Request $request
  13. * @return array|Arrayable|\JsonSerializable
  14. */
  15. public function toArray($request)
  16. {
  17. $data = [];
  18. $data['content'] = PaliText::where('book', $this->book)
  19. ->where('paragraph', $this->paragraph)
  20. ->value('text');
  21. $data['book'] = $this->book;
  22. $data['start'] = $this->paragraph;
  23. return $data;
  24. }
  25. }