public function index(RegistrationFile $File, $registration_id) { $files = $File->where('registration_id', $registration_id)->paginate(30); $types = config('registration.files.types'); $new_types = collect(array_keys($types)); $exist_types = collect($files->lists('type')->toArray()); $intersects = $new_types->intersect($files->lists('type')->toArray()); dd($intersects); return view('registration::files.index', compact('files')); }
public function actionBulk(Request $request) { if (!$request->has('table_records')) { return redirect()->route('registration.files.index'); } $action = $request->input('action', 'delete'); $ids = $request->input('table_records'); $file = RegistrationFile::find($ids[0]); switch ($action) { case 'delete': RegistrationFile::destroy($ids); $message = trans('registration::files.delete_bulk_success'); break; case 'update': foreach ($ids as $id) { RegistrationFile::where('id', $id)->update(['valid' => $request->input('valid')]); } $message = trans('registration::files.update_bulk_success'); break; } return redirect()->route('registration.files.index', $file->registration_id)->with('success', $message); }
public function delete($id, File $File) { $file = $File->where('registration_id', $this->registration->id)->findOrFail($id); $file->delete(); return response()->json(['success' => 1]); }
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); }
public function files() { $files = RegistrationFile::where('registration_id', registrar()->id)->get(); $registration = registrar(); return view('registration::registrar.files', compact('files', 'registration')); }
/** * 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!'); }