/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { $injection = Injection::findOrFail($id); if (Input::hasFile('image')) { $file = Input::file('image'); //Creamos una instancia de la libreria instalada $image = \Image::make(\Input::file('image')); //Ruta donde queremos guardar las imagenes $path = 'img/injections/'; // Guardar Original //$image->save($path.$file->getClientOriginalName()); // Cambiar de tamaño $image->resize(450, 450); $image->save($path . $file->getClientOriginalName()); // Guardar //$image->save($path.'injec_'.$file->getClientOriginalName()); //Guardamos nombre y nombreOriginal en la BD $injection->name = Input::get('name'); $injection->indications = Input::get('indications'); $injection->Dosage = Input::get('Dosage'); $injection->composition = Input::get('composition'); $injection->application = Input::get('application'); $injection->precautions = Input::get('precautions'); $injection->effects = Input::get('effects'); $injection->size = Input::get('sizes'); $injection->price = Input::get('prices'); //dd($request->price); $price_ml = $request->prices / $request->sizes; $injection->price_ml = $price_ml; $injection->due_date = Input::get('due_date'); $injection->image = $file->getClientOriginalName(); $injection->save(); return redirect()->route('injection.index'); } $file = Injection::where('id', $id)->pluck('image'); $injection->name = Input::get('name'); $injection->indications = Input::get('indications'); $injection->Dosage = Input::get('Dosage'); $injection->composition = Input::get('composition'); $injection->application = Input::get('application'); $injection->precautions = Input::get('precautions'); $injection->effects = Input::get('effects'); $injection->size = Input::get('sizes'); $injection->price = Input::get('prices'); $price_ml = $request->prices / $request->sizes; $injection->price_ml = $price_ml; $injection->due_date = Input::get('due_date'); $injection->image = $file; $injection->save(); return redirect()->route('injection.index'); }
public function ejecutar_injection(Request $requestI) { $rules = array('dateApplication' => 'required', 'boosterInjection' => 'required', 'dose' => 'required', 'responsible' => 'required'); $this->validate($requestI, $rules); $dateA = Input::get('dateApplication'); $dateApplication = date(microtime(substr($dateA, 6, 4) . "-" . substr($dateA, 3, 2) . "-" . substr($dateA, 0, 2) . " " . substr($dateA, 10, 6)) * 10000); $boosterI = Input::get('boosterInjection'); $boosterInjection = date(microtime(substr($dateA, 6, 4) . "-" . substr($dateA, 3, 2) . "-" . substr($dateA, 0, 2) . " " . substr($dateA, 10, 6)) * 10000); $price = Injection::where('id', $requestI->injectionName)->pluck('price_ml'); $ic = new InjecctionControl(); $ic->idUser = Auth::id(); $ic->animalName = $requestI->animalName; $ic->diseaseName = $requestI->diseaseName; $ic->injectionName = $requestI->injectionName; $ic->dateApplication = $requestI->dateApplication; $ic->dose = $requestI->dose; $ic->value = $requestI->dose * $price; $ic->responsible = $requestI->responsible; $ic->boosterInjection = $requestI->boosterInjection; $ic->save(); $event = new Calendar(); $event->idUser = Auth::id(); $event->title = 'Vacunacion'; $event->body = 'Programada'; $event->url = 'http://localhost:8000/vaccinationControl'; $event->class = 'Preventivo'; $event->start = $dateApplication; $event->end = $boosterInjection; $event->save(); return redirect()->route('animal.index'); }