TermService.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Services;
  3. use App\Models\DhammaTerm;
  4. use App\Http\Api\ChannelApi;
  5. class TermService
  6. {
  7. public function getCommunityGlossary($lang)
  8. {
  9. $localTermChannel = ChannelApi::getSysChannel(
  10. "_community_term_" . strtolower($lang) . "_",
  11. "_community_term_en_"
  12. );
  13. $result = DhammaTerm::select(['word', 'tag', 'meaning', 'other_meaning'])
  14. ->where('channal', $localTermChannel)
  15. ->get();
  16. return ['items' => $result, 'total' => count($result)];
  17. }
  18. public function getGrammarGlossary($lang)
  19. {
  20. $localTermChannel = ChannelApi::getSysChannel(
  21. "_System_Grammar_Term_" . strtolower($lang) . "_",
  22. "_System_Grammar_Term_en_"
  23. );
  24. $result = DhammaTerm::select(['word', 'tag', 'meaning', 'other_meaning'])
  25. ->where('channal', $localTermChannel)
  26. ->get();
  27. return ['items' => $result, 'total' => count($result)];
  28. }
  29. public function get($id)
  30. {
  31. $result = DhammaTerm::find($id);
  32. return $result;
  33. }
  34. }