/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // if (RegistrationFile::count()) {
     // 	return;
     // }
     // RegistrationFile::truncate();
     // $this->call("OthersTableSeeder");
     $file_type = [1 => 'photo', 2 => 'nid', 3 => 'certificate', 4 => 'transcript', 5 => 'job', 6 => 'marriage', 7 => 'receipt'];
     $PATH = 'https://el-css.edu.om/iis/assets/admissions/';
     $registrations = DB::connection('old')->table('registration')->get();
     foreach ($registrations as $registration) {
         if ($registration->reg_nationalphoto != '') {
             $new_RegistrationFile = new RegistrationFile();
             $new_RegistrationFile->registration_id = $registration->reg_id;
             $new_RegistrationFile->type = 'nid';
             $new_RegistrationFile->valid = 1;
             $new_RegistrationFile->file = $PATH . $registration->reg_nationalphoto;
             try {
                 $new_RegistrationFile->save();
             } catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) {
             } catch (\Codesleeve\Stapler\Exceptions\FileException $e) {
                 echo 'couldnt move file';
             }
             if ($new_RegistrationFile->file->size() < 600) {
                 $new_RegistrationFile->delete();
             }
         }
         if ($registration->reg_eduphoto != '') {
             $new_RegistrationFile = new RegistrationFile();
             $new_RegistrationFile->registration_id = $registration->reg_id;
             $new_RegistrationFile->type = 'certificate';
             $new_RegistrationFile->valid = 1;
             $new_RegistrationFile->file = $PATH . $registration->reg_eduphoto;
             try {
                 $new_RegistrationFile->save();
             } catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) {
             } catch (\Codesleeve\Stapler\Exceptions\FileException $e) {
                 echo 'couldnt move file';
             }
             if ($new_RegistrationFile->file->size() < 600) {
                 $new_RegistrationFile->delete();
             }
         }
         if ($registration->reg_userphoto != '') {
             $new_RegistrationFile = new RegistrationFile();
             $new_RegistrationFile->registration_id = $registration->reg_id;
             $new_RegistrationFile->type = 'photo';
             $new_RegistrationFile->valid = 1;
             $new_RegistrationFile->file = $PATH . $registration->reg_userphoto;
             try {
                 $new_RegistrationFile->save();
             } catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) {
             } catch (\Codesleeve\Stapler\Exceptions\FileException $e) {
                 echo 'couldnt move file';
             }
             if ($new_RegistrationFile->file->size() < 600) {
                 $new_RegistrationFile->delete();
             }
         }
         if ($registration->reg_degreesphoto != '') {
             $new_RegistrationFile = new RegistrationFile();
             $new_RegistrationFile->registration_id = $registration->reg_id;
             $new_RegistrationFile->type = 'transcript';
             $new_RegistrationFile->valid = 1;
             $new_RegistrationFile->file = $PATH . $registration->reg_degreesphoto;
             try {
                 $new_RegistrationFile->save();
             } catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) {
             } catch (\Codesleeve\Stapler\Exceptions\FileException $e) {
                 echo 'couldnt move file';
             }
             if ($new_RegistrationFile->file->size() < 600) {
                 $new_RegistrationFile->delete();
             }
         }
         if ($registration->reg_workphoto != '') {
             $new_RegistrationFile = new RegistrationFile();
             $new_RegistrationFile->registration_id = $registration->reg_id;
             $new_RegistrationFile->type = 'job';
             $new_RegistrationFile->valid = 1;
             $new_RegistrationFile->file = $PATH . $registration->reg_workphoto;
             try {
                 $new_RegistrationFile->save();
             } catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) {
             } catch (\Codesleeve\Stapler\Exceptions\FileException $e) {
                 echo 'couldnt move file';
             }
             if ($new_RegistrationFile->file->size() < 600) {
                 $new_RegistrationFile->delete();
             }
         }
         if ($registration->reg_marriagephoto != '') {
             $new_RegistrationFile = new RegistrationFile();
             $new_RegistrationFile->registration_id = $registration->reg_id;
             $new_RegistrationFile->type = 'marriage';
             $new_RegistrationFile->valid = 1;
             $new_RegistrationFile->file = $PATH . $registration->reg_marriagephoto;
             try {
                 $new_RegistrationFile->save();
             } catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) {
             } catch (\Codesleeve\Stapler\Exceptions\FileException $e) {
                 echo 'couldnt move file';
             }
             if ($new_RegistrationFile->file->size() < 600) {
                 $new_RegistrationFile->delete();
             }
         }
         if ($registration->reg_paymentphoto != '') {
             $new_RegistrationFile = new RegistrationFile();
             $new_RegistrationFile->registration_id = $registration->reg_id;
             $new_RegistrationFile->type = 'receipt';
             $new_RegistrationFile->valid = 1;
             $new_RegistrationFile->file = $PATH . $registration->reg_paymentphoto;
             try {
                 $new_RegistrationFile->save();
             } catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) {
             } catch (\Codesleeve\Stapler\Exceptions\FileException $e) {
                 echo 'couldnt move file';
             }
             if ($new_RegistrationFile->file->size() < 600) {
                 $new_RegistrationFile->delete();
             }
         }
     }
     $this->command->info('file from registration table entered!');
     $registration_files = DB::connection('old')->table('reg_userdocs')->get();
     foreach ($registration_files as $Rfile) {
         $new_RegistrationFile = new RegistrationFile();
         $new_RegistrationFile->registration_id = $Rfile->rud_regid;
         $new_RegistrationFile->type = $file_type[$Rfile->rud_docid];
         $new_RegistrationFile->valid = 1;
         $new_RegistrationFile->file = $PATH . $Rfile->rud_file;
         try {
             $new_RegistrationFile->save();
         } catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) {
         } catch (\Codesleeve\Stapler\Exceptions\FileException $e) {
             echo 'couldnt move file';
         }
         if ($new_RegistrationFile->file->size() < 600) {
             $new_RegistrationFile->delete();
         }
     }
     $this->command->info('file from reg_doc table entered!');
 }