/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $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($boosterI, 6, 4) . "-" . substr($boosterI, 3, 2) . "-" . substr($boosterI, 0, 2) . " " . substr($boosterI, 10, 6)) * 10000); //dd($request->diseaseName); $animalName = Animal::where('id', $request->animalName)->pluck('nombre'); $diseaseName = Disease::where('id', $request->diseaseName)->pluck('name'); $vaccineName = Vaccine::where('id', $request->vaccineName)->pluck('name'); $vc = new VaccinationControl(); $vc->idUser = Auth::id(); $vc->animalName = $animalName; $vc->diseaseName = $diseaseName; $vc->vaccineName = $vaccineName; $vc->dateApplication = Input::get('dateApplication'); $vc->dose = Input::get('dose'); $vc->responsible = Input::get('responsible'); $vc->boosterInjection = Input::get('boosterInjection'); //dd($vc); $vc->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('vaccinationControl.show'); }
/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request) { $animals = Animal::where('idUser', Auth::id())->where('id', $request->id)->get(); $vaccines = VaccinationControl::where('vaccination_controls.idUser', Auth::id())->where('vaccination_controls.animalName', $request->id)->join('vaccines', 'vaccines.id', '=', 'vaccination_controls.vaccineName')->join('diseases', 'diseases.id', '=', 'vaccination_controls.diseaseName')->select('vaccines.nameV', 'diseases.name', 'vaccination_controls.dateApplication', 'vaccination_controls.dose')->get(); $injecctions = InjecctionControl::where('injecction_controls.idUser', Auth::id())->where('injecction_controls.animalName', $request->id)->join('injections', 'injections.id', '=', 'injecction_controls.injectionName')->join('diseases', 'diseases.id', '=', 'injecction_controls.diseaseName')->select('injections.name', 'diseases.name', 'injecction_controls.dateApplication', 'injecction_controls.dose')->get(); $animal = Animal::where('id', $request->id)->get(); return view('reports.show', compact('animals', 'vaccines', 'injecctions', 'animal')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $rules = ['animal' => 'required', 'id_raza' => ['required', 'not_in:0'], 'id_estado' => ['required', 'not_in:0']]; $this->validate($request, $rules); $datos = $request->all(); $animal = \App\Animal::find($id); $animal->animal = $datos['animal']; $animal->id_raza = $datos['id_raza']; $animal->descripcion = $datos['descripcion']; $animal->id_estado = $datos['id_estado']; $animal->save(); $request->session()->flash('msj_success', 'Se ha actualizado correctamente el animal: ' . $datos['animal']); return redirect()->route('animales.index'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $Request) { $Animal = new Animal(); $Animal->idAnimal = $Request->codigo; $Animal->procedencia = $Request->procedencia; $Animal->codigo = $Request->codigo; $Animal->raza = $Request->raza; $Animal->sexo = $Request->sexo; $Animal->estado = $Request->estado; $Animal->fechaDestete = $Request->fechadestete; $Animal->pesoNacer = $Request->pesoNacer; $Animal->pesoDestete = $Request->pesoDestete; $Animal->fechaConsumo = $Request->fechaConsumo; $Animal->codigoParto = $Request->codParto; $Animal->fechaParto = $Request->fechaparto; $Animal->codigoMadre = $Request->codMadre; $Animal->Edad = $Request->edad; $Animal->razaMadre = $Request->razamadre; $Animal->razaPadre = $Request->razapadre; $Animal->tipoAnimal = $Request->tipoAnimal; $Animal->remember_token = $Request->_token; $Animal->save(); return redirect('MenuPrincipal'); }
public function milk_production($id) { $animals = Animal::where('idUser', Auth::id())->get(); return view('animals.milk_production', compact('animals')); }
public function getFiltraranimal(Request $request) { if (!$request->ajax()) { abort(403); } $datos = array(); $inputs = $request->all(); if (empty($inputs['search'])) { $animales = \App\Animal::select(\DB::raw('SQL_CALC_FOUND_ROWS *'), 'id')->where('id', '>', 0)->take($inputs['limit'])->skip($inputs['offset'])->orderBy('created_at', 'ASC')->get(); } else { $animales = \App\Animal::select(\DB::raw('SQL_CALC_FOUND_ROWS *'), 'id')->where('animal', 'LIKE', '%' . $inputs["search"] . '%')->take($inputs['limit'])->skip($inputs['offset'])->orderBy('created_at', 'ASC')->get(); } $cantidad = \DB::select(\DB::raw("SELECT FOUND_ROWS() AS total;")); $cantidad = $cantidad[0]->total; $n = 1; foreach ($animales as $animal) { $url = '<a href="' . route('animales.edit', $animal->id) . '" class="btn btn-xs btn-success"><i class="fa fa-btn fa-edit"></i>Editar</a>'; $datos[] = ['num' => $n++, 'animal' => $animal->animal, 'act' => $url]; } return \Response::json(['total' => $cantidad, 'rows' => $datos]); }
public function modificarAnimal(Animal $animal) { DB::table('animal')->where('idAnimal', $animal->getIdAnimal())->update(['Codigo' => $animal->getCodigo(), 'Nombre' => $animal->getNombre(), 'Sexo' => $animal->getSexo(), 'Esterilizacion' => $animal->getEsterilizacion(), 'FechaDeNacimiento' => $animal->getFechaNacimiento(), 'Estado' => $animal->getEstado(), 'Observacion' => $animal->getObservacion(), 'Color' => $animal->getColor(), 'Pedigree' => $animal->getPedigree(), 'NumPedigree' => $animal->getNumPedigree(), 'Cliente_idCliente' => $animal->getIdCliente(), 'Raza_idRaza' => $animal->getIdraza()]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Animal::destroy($id); alert()->success('', 'Animal successfully deleted!'); return redirect('animal'); }