Example #1
0
 public function store(Request $request)
 {
     $file = new File();
     $file->fill($request->only('type', 'file'));
     $file->registration_id = daress_registerd()->id;
     $file->save();
     $file->isImage = substr($file->file->contentType(), 0, 5) == 'image';
     $file->file_url = asset($file->file->url());
     return $file;
 }
Example #2
0
 public function store(CreateFileRequest $request)
 {
     if (!$this->registration->step->edit_form) {
         return redirect()->route('registration.registrar.index');
     }
     $file = new File();
     $file->fill($request->only('type', 'file'));
     $file->registration_id = $this->registration->id;
     $file->save();
     $file->isImage = substr($file->file->contentType(), 0, 5) == 'image';
     $file->file_url = asset($file->file->url());
     return $file;
 }
 public function registrarPostUpload(Request $request)
 {
     $registrar = Auth::guard('api_registration')->user();
     $file = new RegistrationFile();
     $file->fill($request->only('type', 'file'));
     $file->registration_id = $registrar->id;
     if ($file->save()) {
         $step = RegistrationStep::find($registrar->registration_step_id)->children()->where('files_processing', 1)->first();
         if ($step) {
             $registrar->registration_step_id = $step->id;
             $registrar->save();
             event(new RegistrationUpdated($registrar));
             event(new RegistrationStepChanged($registrar, ['comment' => 'قام برفع ملف']));
         }
     }
     $attachments = $file->urlsForAttachment('file');
     foreach ($attachments as $key => $attachment) {
         $attachments[$key] = asset($attachment);
     }
     $file->attachments = $attachments;
     return response()->json($file, 200, [], JSON_NUMERIC_CHECK);
 }
 /**
  * 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!');
 }