CourseApi.php 906 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Http\Api;
  3. use App\Models\CourseMember;
  4. use Illuminate\Support\Facades\Log;
  5. class CourseApi{
  6. public static function getStudentChannels($courseId){
  7. $channels = [];
  8. $studentsChannel = CourseMember::where('course_id',$courseId)
  9. ->whereNotNull('channel_id')
  10. ->where('role','student')
  11. ->whereIn('status',['joined','accepted','agreed'])
  12. ->select('channel_id')
  13. ->orderBy('created_at')
  14. ->get();
  15. foreach ($studentsChannel as $key => $channel) {
  16. $channels[] = $channel->channel_id;
  17. }
  18. return $channels;
  19. }
  20. public static function role($courseId,$userUid){
  21. $role = CourseMember::where('course_id',$courseId)
  22. ->where('user_id')
  23. ->value('role');
  24. return $role;
  25. }
  26. }