/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call("OthersTableSeeder");
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Teacher::truncate();
     //get all Teacher (group_id =2)
     $old_teachers = DB::connection('old')->table('users')->where('user_groupid', 2)->get();
     foreach ($old_teachers as $teacher) {
         $new_teachers = new Teacher();
         //$new_teachers->id = $teacher->user_id;
         $new_teachers->name = $teacher->user_fullname;
         $new_teachers->username = $teacher->user_code;
         $new_teachers->mobile = $teacher->user_phone;
         //email
         $new_email = $teacher->user_code . '@css.edu.om';
         $teacher_email = !empty($teacher->user_email) ? $teacher->user_email : $new_email;
         $new_teachers->email = $teacher_email;
         //pwd
         $teacher_password = !empty($teacher->user_phone) ? bcrypt($teacher->user_phone) : bcrypt('123456');
         $new_teachers->password = $teacher_password;
         //datetime
         $new_teachers->created_at = new DateTime();
         $new_teachers->updated_at = new DateTime();
         $new_teachers->save();
     }
     $this->command->info('teachers transfered!');
 }