public function siguientePedido() { $pedidoAnterior = Factura::where('cliente_id', '=', $this->id)->orderBy('pedido', 'desc')->first(); if ($pedidoAnterior) { return $pedidoAnterior->pedido + 1; } else { return 1; } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $proveedores = Proveedor::find($id); if (is_null($proveedores)) { return Redirect::route('proveedores.index')->with('global', '<i class="fa fa-exclamation fa-fw x3"></i> Pagina no encontrada'); } $user = DB::table('users')->where('id', '=', $proveedores->id_user)->first(); $facturas = Factura::where('id_proveedor', '=', $proveedores->id)->orderBy('created_at', 'DESC')->paginate(10); $totalFacturas = Factura::where('id_proveedor', '=', $proveedores->id)->count(); $contador = 0; //dd($totalFacturas); return View::make('proveedores.show', array('proveedores' => $proveedores, 'user' => $user))->with('facturas', $facturas)->with('totalFacturas', $totalFacturas)->with('contador', $contador); //return var_dump($user); }
public function getFiltroPorNotas() { try { $input = Input::all(); $facturas = Factura::where('notas', 'like', '%' . $input['notas'] . '%')->orderBy('id', 'desc')->paginate(2); Session::flash('mensajeOk', 'Se ha realizado la búsqueda de facturas que contienen <strong>' . $input['notas'] . '</strong> en las notas.'); return View::make('facturas.listado')->with(compact('facturas', 'input')); } catch (Exception $e) { Session::flash('mensajeError', 'Ha ocurrido un error al intentar mostrar facturas con <strong>' . $input['notas'] . '</strong> en las notas.'); return Redirect::to('facturas/listado'); } }