public function updateamount(Request $request, $id) { $validator = Validator::make(Input::all(), Expensive::$rules); if ($validator->passes()) { $project = Project::find($id); $viatico = new Expensive(); $viatico->project_id = $project->id; $viatico->concepto = Input::get('concepto'); $viatico->monto = Input::get('monto'); $viatico->fecha = Input::get('fecha'); /* * validar si existe una imagen */ if (Input::has('file')) { $user = Input::get('user_id'); $projectnumber = $project->id; $file = $request->file('file'); $ruta = '/files/' . $user . '/' . $projectnumber . '/'; $nombre = sha1(Carbon::now()) . '.' . $file->guessExtension(); $fileupload = $file->move(getcwd() . $ruta, $nombre); $viatico->ruta = $fileupload; } $viatico->save(); /* * movimiento en la tabla de proyecto para el monto restante */ $monto = Input::get('monto'); DB::table('projects')->where('id', $id)->update(['montocambiante' => $monto]); DB::table('projects')->where('id', $id)->decrement('montorestante', $monto); Flash::overlay('Amount Updated Successfully'); return redirect('projects'); } return redirect('projects/' . $id . '/uamount')->withErrors($validator)->withInput(Input::all())->with('message', 'There some problems with the inputs, please review and submit again :D !!'); }
public function download($id) { $file = Expensive::findOrFail($id); $ruta = $file->ruta; return Response::download($ruta); }