2
0

SuggestionApi.php 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Http\Api;
  3. use App\Models\SentPr;
  4. use App\Models\Discussion;
  5. use App\Models\Sentence;
  6. use App\Http\Api\PaliTextApi;
  7. class SuggestionApi{
  8. public static function getCountBySent($book,$para,$start,$end,$channel,$type="suggestion"){
  9. $count['suggestion'] = SentPr::where('book_id',$book)
  10. ->where('paragraph',$para)
  11. ->where('word_start',$start)
  12. ->where('word_end',$end)
  13. ->where('channel_uid',$channel)
  14. ->count();
  15. $sentId = Sentence::where('book_id',$book)
  16. ->where('paragraph',$para)
  17. ->where('word_start',$start)
  18. ->where('word_end',$end)
  19. ->where('channel_uid',$channel)
  20. ->value('uid');
  21. if($sentId){
  22. $count['discussion'] = Discussion::where('res_id',$sentId)
  23. ->whereNull('parent')
  24. ->count();
  25. }
  26. return $count;
  27. }
  28. }