GrammarGuideController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Http\Api\ChannelApi;
  4. use App\Models\DhammaTerm;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Http\Response;
  7. class GrammarGuideController extends Controller
  8. {
  9. /**
  10. * Display a listing of the resource.
  11. *
  12. * @return Response
  13. */
  14. public function index()
  15. {
  16. //
  17. }
  18. /**
  19. * Store a newly created resource in storage.
  20. *
  21. * @return Response
  22. */
  23. public function store(Request $request)
  24. {
  25. //
  26. }
  27. /**
  28. * Display the specified resource.
  29. *
  30. * @param DhammaTerm $dhammaTerm
  31. * @return 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. * @return Response
  56. */
  57. public function update(Request $request, DhammaTerm $dhammaTerm)
  58. {
  59. //
  60. }
  61. /**
  62. * Remove the specified resource from storage.
  63. *
  64. * @return Response
  65. */
  66. public function destroy(DhammaTerm $dhammaTerm)
  67. {
  68. //
  69. }
  70. }