public function run()
 {
     Role::create(['role_name' => 'Learner']);
     Role::create(['role_name' => 'TeachingAssistant']);
     Role::create(['role_name' => 'Instructor']);
     Role::create(['role_name' => 'Approver']);
 }
 private function processStudentsInCourse($data, $courseId)
 {
     //first add them the User table
     //then add them to the user_course table.
     $arr = array();
     $role = Role::where('role_name', '=', 'Learner')->first();
     foreach ($data as $row) {
         $this->saveUser($row->id, $row->name, $row->sortable_name);
         $userCourse = UserCourse::firstOrNew(array('user_id' => $row->id, 'course_id' => $courseId));
         $userCourse->user_id = $row->id;
         $userCourse->course_id = $courseId;
         $userCourse->role = $role->id;
         $userCourse->save();
         $arr[] = $userCourse;
     }
     return $arr;
 }
Example #3
0
 public function getRole($role_name)
 {
     return Role::where('role_name', '=', $role_name)->first();
 }