VocabularyController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Vocabulary;
  4. use Illuminate\Http\Request;
  5. use App\Http\Resources\VocabularyResource;
  6. class VocabularyController extends Controller
  7. {
  8. /**
  9. * Display a listing of the resource.
  10. *
  11. * @return \Illuminate\Http\Response
  12. */
  13. public function index(Request $request)
  14. {
  15. //
  16. switch ($request->get("view")) {
  17. case 'key':
  18. $result = Vocabulary::where('word_en','like',$request->get("key")."%")->take(20)->get();
  19. if($result){
  20. return $this->ok(['rows'=>VocabularyResource::collection($result),'count'=>count($result)]);
  21. }else{
  22. return $this->error();
  23. }
  24. break;
  25. }
  26. }
  27. /**
  28. * Store a newly created resource in storage.
  29. *
  30. * @param \Illuminate\Http\Request $request
  31. * @return \Illuminate\Http\Response
  32. */
  33. public function store(Request $request)
  34. {
  35. //
  36. }
  37. /**
  38. * Display the specified resource.
  39. *
  40. * @param \App\Models\Vocabulary $vocabulary
  41. * @return \Illuminate\Http\Response
  42. */
  43. public function show(Vocabulary $vocabulary)
  44. {
  45. //
  46. }
  47. /**
  48. * Update the specified resource in storage.
  49. *
  50. * @param \Illuminate\Http\Request $request
  51. * @param \App\Models\Vocabulary $vocabulary
  52. * @return \Illuminate\Http\Response
  53. */
  54. public function update(Request $request, Vocabulary $vocabulary)
  55. {
  56. //
  57. }
  58. /**
  59. * Remove the specified resource from storage.
  60. *
  61. * @param \App\Models\Vocabulary $vocabulary
  62. * @return \Illuminate\Http\Response
  63. */
  64. public function destroy(Vocabulary $vocabulary)
  65. {
  66. //
  67. }
  68. }