SystemTermController.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\DhammaTerm;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\Http;
  6. class SystemTermController 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 $lang,string $word)
  34. {
  35. //
  36. $url = "https://staging.wikipali.org/api/v2/channel-name/_System_Grammar_Term_{$lang}_";
  37. $response = Http::get($url);
  38. if($response->successful()){
  39. $channelId = $response['data']['uid'];
  40. $term = DhammaTerm::where('channal',$channelId)
  41. ->where('tag',':abbr:')
  42. ->where('word',$word)
  43. ->first();
  44. if($term){
  45. return $this->ok($term);
  46. }else{
  47. return $this->error('no term');
  48. }
  49. }else{
  50. return $this->error('no channel');
  51. }
  52. }
  53. /**
  54. * Update the specified resource in storage.
  55. *
  56. * @param \Illuminate\Http\Request $request
  57. * @param \App\Models\DhammaTerm $dhammaTerm
  58. * @return \Illuminate\Http\Response
  59. */
  60. public function update(Request $request, DhammaTerm $dhammaTerm)
  61. {
  62. //
  63. }
  64. /**
  65. * Remove the specified resource from storage.
  66. *
  67. * @param \App\Models\DhammaTerm $dhammaTerm
  68. * @return \Illuminate\Http\Response
  69. */
  70. public function destroy(DhammaTerm $dhammaTerm)
  71. {
  72. //
  73. }
  74. }