SentenceAttachmentController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Http\Requests\StoreSentenceAttachmentRequest;
  4. use App\Http\Requests\UpdateSentenceAttachmentRequest;
  5. use Illuminate\Http\Request;
  6. use App\Models\SentenceAttachment;
  7. use App\Http\Resources\SentenceAttachmentResource;
  8. class SentenceAttachmentController extends Controller
  9. {
  10. /**
  11. * Display a listing of the resource.
  12. *
  13. * @return \Illuminate\Http\Response
  14. */
  15. public function index(Request $request)
  16. {
  17. switch ($request->view) {
  18. case 'sentence':
  19. $table = SentenceAttachment::where('sentence_id', $request->get('id'));
  20. break;
  21. default:
  22. return $this->error('known view');
  23. break;
  24. }
  25. $table->orderBy($request->get('order', 'updated_at'), $request->get('dir', 'desc'));
  26. $count = $table->count();
  27. $table->skip($request->get("offset", 0))
  28. ->take($request->get('limit', 1000));
  29. $result = $table->get();
  30. return $this->ok([
  31. "rows" => SentenceAttachmentResource::collection($result),
  32. "count" => $count
  33. ]);
  34. }
  35. /**
  36. * Store a newly created resource in storage.
  37. *
  38. * @param \App\Http\Requests\StoreSentenceAttachmentRequest $request
  39. * @return \Illuminate\Http\Response
  40. */
  41. public function store(Request $request)
  42. {
  43. //
  44. }
  45. /**
  46. * Display the specified resource.
  47. *
  48. * @param \App\Models\SentenceAttachment $sentenceAttachment
  49. * @return \Illuminate\Http\Response
  50. */
  51. public function show(Request $sentenceAttachment)
  52. {
  53. //
  54. }
  55. /**
  56. * Update the specified resource in storage.
  57. *
  58. * @param \App\Http\Requests\UpdateSentenceAttachmentRequest $request
  59. * @param \App\Models\SentenceAttachment $sentenceAttachment
  60. * @return \Illuminate\Http\Response
  61. */
  62. public function update(Request $request, SentenceAttachment $sentenceAttachment)
  63. {
  64. //
  65. }
  66. /**
  67. * Remove the specified resource from storage.
  68. *
  69. * @param \App\Models\SentenceAttachment $sentenceAttachment
  70. * @return \Illuminate\Http\Response
  71. */
  72. public function destroy(SentenceAttachment $sentenceAttachment)
  73. {
  74. //
  75. }
  76. }