/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(CreateMouseRequest $request, $id) { $input = Input::except('_method', '_token'); $mouse = Mouse::findOrFail($id); $mouse->update($input); return redirect('projects/' . $mouse->project_id); }
/** * Create many plates simultaneously. * @param CreatePlateRequest $request * @param $number * @return \Illuminate\View\View */ public function storeMany(CreatePlateRequest $request) { $count = $request->get('plateNumber'); $start = $request->get('name'); $total = $start + $count; while ($start < $total) { $data = ['name' => $start, 'mouse_id' => $request->get('mouse_id'), 'plate_type' => $request->get('plate_type'), 'description' => $request->get('description'), 'isProcessed' => $request->get('isProcessed')]; $plate = Plate::create($data); $mouse = Mouse::findOrFail($plate->mouse_id); $start++; } return view('plates.create', compact('mouse')); }
/** * Get the amount of plates per mouse that have been processed. * @param \App\Mouse $mouse * @return mixed */ public function getCompletedCount(Mouse $mouse) { $count = $mouse->plates()->where('isProcessed', 1)->count(); return $count; }