Ejemplo n.º 1
0
 public function getNext($id)
 {
     // TODO: Delete unused 'count'
     $userid = $this->auth->user()->id;
     $batchId = $this->auth->user()->batch_id;
     $batch = \App\Batch::find($batchId);
     if ($batch == null) {
         \DebugBar::warning('$batch==null:');
         $batch = $this->newBatch($id, $userid);
         $this->auth->user()->batch_id = $batch->id;
         $this->auth->user()->save();
     } elseif ($batch->remain_count == 0) {
         \DebugBar::warning('$batch->remain_count == 0');
         $standard = \App\StandardItem::find($batch->standard_item_id);
         // if user owns no valid batch or he/she has already done a batch
         $batch = $this->newBatch($id, $userid);
         if ($batch == null) {
             return view('tag.no_more', ['user' => $this->auth->user(), 'dataset' => \App\Dataset::find($id)]);
         }
         $this->auth->user()->batch_id = $batch->id;
         $this->auth->user()->save();
         return view('tag.done', ['user' => $this->auth->user(), 'dataset' => \App\Dataset::find($id), 'standard' => $standard]);
     }
     $standard = \App\StandardItem::find($batch->standard_item_id);
     $items = $standard->Items;
     $item = $items[$batch->remain_count - 1];
     return view('tag.tag', ['user' => $this->auth->user(), 'dataset' => \App\Dataset::find($id), 'standard' => $standard, 'batch' => $batch, 'item' => $item]);
 }