TermVocabularyController.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\DhammaTerm;
  4. use Illuminate\Http\Request;
  5. use App\Http\Resources\TermVocabularyResource;
  6. use App\Http\Api\ChannelApi;
  7. class TermVocabularyController extends Controller
  8. {
  9. /**
  10. * Display a listing of the resource.
  11. *
  12. * @return \Illuminate\Http\Response
  13. */
  14. public function index(Request $request)
  15. {
  16. //
  17. $table = DhammaTerm::select(['guid','word','tag','meaning','other_meaning']);
  18. switch ($request->get('view')) {
  19. case "grammar":
  20. $localTerm = ChannelApi::getSysChannel(
  21. "_System_Grammar_Term_".strtolower($request->get('lang'))."_",
  22. "_System_Grammar_Term_en_"
  23. );
  24. if(!$localTerm){
  25. return $this->error('no term channel');
  26. }
  27. $table = $table->where('channal',$localTerm);
  28. break;
  29. case "studio":
  30. break;
  31. case "user":
  32. break;
  33. case "community":
  34. $localTerm = ChannelApi::getSysChannel(
  35. "_community_term_".strtolower($request->get('lang'))."_",
  36. "_community_term_en_"
  37. );
  38. if(!$localTerm){
  39. return $this->error('no term channel');
  40. }
  41. $table = $table->where('channal',$localTerm);
  42. break;
  43. }
  44. $result = $table->get();
  45. return $this->ok(["rows"=>TermVocabularyResource::collection($result),'count'=>count($result)]);
  46. }
  47. /**
  48. * Store a newly created resource in storage.
  49. *
  50. * @param \Illuminate\Http\Request $request
  51. * @return \Illuminate\Http\Response
  52. */
  53. public function store(Request $request)
  54. {
  55. //
  56. }
  57. /**
  58. * Display the specified resource.
  59. *
  60. * @param \App\Models\DhammaTerm $dhammaTerm
  61. * @return \Illuminate\Http\Response
  62. */
  63. public function show(DhammaTerm $dhammaTerm)
  64. {
  65. //
  66. }
  67. /**
  68. * Update the specified resource in storage.
  69. *
  70. * @param \Illuminate\Http\Request $request
  71. * @param \App\Models\DhammaTerm $dhammaTerm
  72. * @return \Illuminate\Http\Response
  73. */
  74. public function update(Request $request, DhammaTerm $dhammaTerm)
  75. {
  76. //
  77. }
  78. /**
  79. * Remove the specified resource from storage.
  80. *
  81. * @param \App\Models\DhammaTerm $dhammaTerm
  82. * @return \Illuminate\Http\Response
  83. */
  84. public function destroy(DhammaTerm $dhammaTerm)
  85. {
  86. //
  87. }
  88. }