Exemplo n.º 1
0
 public function create()
 {
     $iSet = IndexSet::lists('name', 'id');
     $iAll = IndexSet::all();
     $i7 = I7Index::lists('index', 'id');
     $i5 = I5Index::lists('index', 'id');
     $pg = ProjectGroup::lists('name', 'id');
     $user = Auth::user();
     $batches = $user->batches->lists('batch_name', 'id');
     return view('samples.create', ['iSet' => $iSet, 'iAll' => $iAll, 'i7' => $i7, 'i5' => $i5, 'pg' => $pg, 'user' => $user, 'batches' => $batches]);
 }
Exemplo n.º 2
0
 public function create()
 {
     $iSet = IndexSet::lists('name', 'id');
     $iAll = IndexSet::all();
     $i7 = I7Index::lists('index', 'id');
     $i5 = I5Index::lists('index', 'id');
     $pg = ProjectGroup::lists('name', 'id');
     $user = Auth::user();
     $batches = Batch::where('user_id', $user->id)->orderBy('created_at', 'desc')->lists('batch_name', 'id');
     return view('samples.create', ['iSet' => $iSet, 'iAll' => $iAll, 'i7' => $i7, 'i5' => $i5, 'pg' => $pg, 'user' => $user, 'batches' => $batches]);
 }
 /**
  * @param Request $request
  * @return mixed
  */
 public function validateFile(ImportSampleRequest $request)
 {
     // Get form input and check if dupes are ok
     $input = $request->all();
     $dupes_ok = isset($input['dupes_ok']);
     $instument_lane = 1;
     $file = array('sampleFile' => Input::file('sampleFile'));
     // setting up rules
     /*$rules = array('sampleFile' => array('required', 'mimes:csv,txt'),
                 'plate' => array('regex:/^[a-zA-Z0-9-]{1,120}$/' , 'max:120'),
     
                 'well' => array('regex:/^[a-zA-Z0-9-]{1,120}$/', 'max:120'),
     
                 'description' => array('regex:/^[a-zA-Z0-9-]{1,120}$/' , 'max:120'),
     
                 'runs_remaining' => array('integer', 'between:1,60'),
     
                 'instrument_lane' => array('integer', 'between:1,8'),
             );*/
     //mimes:jpeg,bmp,png and for max size max:10000
     // doing the validation, passing post data, rules and the messages
     $rules = array();
     $validator = Validator::make($file, $rules);
     if ($validator->fails()) {
         // send back to the page with the input data and errorBag
         return Redirect::to('import')->withInput()->withErrors($validator);
     } else {
         // checking file is valid.
         //dd(Request::file('sampleFile')->getExtension());
         if (Input::file('sampleFile')->isValid()) {
             $this->i7Indexes = I7Index::lists('sequence', 'index');
             $this->i7IndexSetArray = I7Index::lists('index_set_id', 'index');
             $this->i5Indexes = I5Index::lists('sequence', 'index');
             $this->i5IndexSetArray = I5Index::lists('index_set_id', 'index');
             $this->samplesList = DB::table('samples')->lists('sample_id');
             $this->loadExistingSamples(Input::get()['batch_id']);
             $this->csvToArray(Request::file('sampleFile'), ',', $dupes_ok);
             $this->generateErrors();
             if (Count($this->stringErrors)) {
                 Session::flash('error', $this->stringErrors);
             } else {
                 if ($this->checkBatchCompatibility(Input::get()['batch_id'])) {
                     $this->addData(Request::file('sampleFile'), Input::get()['batch_id'], Input::get()['plate'], Input::get()['well'], Input::get()['description'], Input::get()['runs_remaining'], $instument_lane);
                     Session::flash('success', "File Upload Successful");
                 } else {
                     array_push($this->stringErrors, "File is not compatible with the batch selected.");
                     Session::flash('error', $this->stringErrors);
                 }
             }
             return Redirect::to('import')->withInput();
         } else {
             // sending back with error message.
             array_push($this->stringErrors, "Upload file is not valid.");
             Session::flash('error', $this->stringErrors);
             return Redirect::to('import')->withInput();
         }
     }
 }