CourseApi.php 797 B

123456789101112131415161718192021222324252627
  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. ->select('channel_id')
  11. ->orderBy('created_at')
  12. ->get();
  13. foreach ($studentsChannel as $key => $channel) {
  14. $channels[] = $channel->channel_id;
  15. }
  16. return $channels;
  17. }
  18. public static function role($courseId,$userUid){
  19. $role = CourseMember::where('course_id',$courseId)
  20. ->where('user_id')
  21. ->value('role');
  22. return $role;
  23. }
  24. }