Esempio n. 1
0
 private function findById($id)
 {
     return Batch::find($id);
 }
 public function postLabel($id, Request $req)
 {
     $userid = $this->auth->user()->id;
     $this->auth->user()->points += 10;
     // TODO: decide the point
     $this->auth->user()->save();
     $label = $req->get('label');
     $itemId = $req->get('item');
     $batchId = $req->get('batch');
     \Log::info($label . " " . $itemId . " " . $batchId);
     //        $batchId = $this->auth->user()->batch_id;
     $batch = \App\Batch::find($batchId);
     $batch->remain_count--;
     $batch->save();
     $user_item = new \App\ItemUserRelation();
     $user_item->fill(['batch_id' => $batchId, 'item_id' => $itemId, 'user_id' => $userid]);
     $user_item->label = $label == 'True';
     $user_item->save();
     return redirect('/tag/' . $id);
 }
Esempio n. 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $batch = Batch::find($id);
     $batch->delete();
     return redirect('batch');
 }
Esempio n. 4
0
 public function checkBatchCompatibility(Sample $sample)
 {
     // Set i5 indexes if not null
     if ($sample->i5_index_id) {
         $i5 = $sample->i5_index->index_set_id;
         $new_i5_index_id = $sample->i5_index->id;
     }
     // Set i7 indexes
     $i7 = $sample->i7_index->index_set_id;
     $new_i7_index_id = $sample->i7_index->id;
     $currentIndexSet = IndexSet::find($i7);
     // Get Batch and loop through its samples
     $batch = Batch::find($sample->batch_id);
     if (count($batch->samples)) {
         foreach ($batch->samples as $s) {
             // Must be from the same index set
             if ($currentIndexSet->id != $s->i7_index->index_set_id) {
                 Session::flash('flash_message', "Index set mismatch!   Existing batch is " . $s->i7_index->IndexSet->name);
                 return false;
             }
             // If both i7 & i5 are already used
             if ($s->i5_index_id) {
                 if ($s->i7_index_id == $new_i7_index_id && $s->i5_index_id == $new_i5_index_id) {
                     Session::flash('flash_message', 'I7 and I5 combination already in batch');
                     return false;
                 }
                 // If single index and new i7 is already in batch
             } elseif ($s->i7_index_id == $new_i7_index_id) {
                 Session::flash('flash_message', 'Index conflict!   New I7 index already in single index batch ');
                 return false;
             }
             // If using dual index when batch is single
             if ($sample->i5_index_id && !$s->i5_index_id) {
                 Session::flash('flash_message', 'Batch is single index! New sample is dual   Existing Index set ' . $s->i7_index->IndexSet->name);
                 return false;
                 // Or vice versa
             } elseif ($s->i5_index_id && !$sample->i5_index_id) {
                 Session::flash('flash_message', "Batch is dual index! New sample is single.   Existing Index set " . $s->i7_index->IndexSet->name);
                 return false;
             }
         }
     }
     Session::flash('success_message', 'Sample added');
     return true;
 }
 /**
  * @param $batchId
  * @return mixed
  */
 private function getBatchSamples($batchId)
 {
     $batch = Batch::find($batchId);
     return $batch->samples;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $productionSchedule = Batch::find($id);
     Activity::log('Cancelled production schedule #' . $productionSchedule->id . '.');
     $productionSchedule->delete();
     return Redirect::action('ProductionController@index')->with('status', 'Production schedule was successfully updated.');
 }