2
0

GrammarGuideController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\DhammaTerm;
  4. use App\Http\Api\ChannelApi;
  5. use Illuminate\Http\Request;
  6. class GrammarGuideController extends Controller
  7. {
  8. /**
  9. * Display a listing of the resource.
  10. *
  11. * @return \Illuminate\Http\Response
  12. */
  13. public function index()
  14. {
  15. //
  16. }
  17. /**
  18. * Store a newly created resource in storage.
  19. *
  20. * @param \Illuminate\Http\Request $request
  21. * @return \Illuminate\Http\Response
  22. */
  23. public function store(Request $request)
  24. {
  25. //
  26. }
  27. /**
  28. * Display the specified resource.
  29. *
  30. * @param \App\Models\DhammaTerm $dhammaTerm
  31. * @return \Illuminate\Http\Response
  32. */
  33. public function show(string $id)
  34. {
  35. //
  36. $param = explode('_',$id);
  37. $localTermChannel = ChannelApi::getSysChannel(
  38. "_System_Grammar_Term_".strtolower($param[1])."_",
  39. "_System_Grammar_Term_en_"
  40. );
  41. if(!$localTermChannel){
  42. return $this->error('no term channel');
  43. }
  44. $result = DhammaTerm::where('word',$param[0])
  45. ->where('channal',$localTermChannel)->first();
  46. if($result){
  47. return $this->ok("# {$result->meaning}\n {$result->note}");
  48. }else{
  49. return $this->ok("# {$id}\n no record");
  50. }
  51. }
  52. /**
  53. * Update the specified resource in storage.
  54. *
  55. * @param \Illuminate\Http\Request $request
  56. * @param \App\Models\DhammaTerm $dhammaTerm
  57. * @return \Illuminate\Http\Response
  58. */
  59. public function update(Request $request, DhammaTerm $dhammaTerm)
  60. {
  61. //
  62. }
  63. /**
  64. * Remove the specified resource from storage.
  65. *
  66. * @param \App\Models\DhammaTerm $dhammaTerm
  67. * @return \Illuminate\Http\Response
  68. */
  69. public function destroy(DhammaTerm $dhammaTerm)
  70. {
  71. //
  72. }
  73. }