public function postNuevaventa(Request $request) { try { $venta = new Venta(); $venta->total = $request->get('total'); $venta->fecha = $request->get('fecha'); $venta->personal_id = Auth::user()->personal->id; $venta->save(); foreach ($request->get('ordenes') as $orden) { $venta->ordenes()->attach($orden['idorden']); } $ordenes = Orden::doesntHave('ventas')->where('status', '=', '1')->with('platillos', 'personal')->get(); return array("Msg" => "Registro Exitoso", "Codigo" => "01", "Bandera" => true, "Ordenes" => $ordenes); } catch (Exception $e) { return array("Msg" => $e->getMessage(), "Codigo" => $e->getCode(), "Bandera" => false); } }
public function getReporteshoy() { $today = Carbon::toDay()->toDateString(); $ventas = Venta::where('fecha', '=', $today)->count(); $platillos = Orden::where(DB::raw('DATE(created_at)'), $today)->get()->sum('platillo_count'); $ordenes = Orden::where(DB::raw('DATE(created_at)'), $today)->get()->count(); $total = Orden::where(DB::raw('DATE(created_at)'), $today)->with('platillos')->get()->sum('platillo_total'); return view('reportes.hoy', compact('ventas', 'platillos', 'ordenes', 'total')); }
/*$users=Personal::has('user')->with('user'); return $users->with('Rol')->get();*/ /*return User::has('personal')->with('personal','rol')->get();*/ /*$pers=Personal::first(); return $pers->getDates()->createdat;*/ /*return Ingrediente::with('categoria')->get();*/ /*return CategoriaIngrediente::with('ingredientes')->get();*/ /*return Orden::with('platillos')->find(1);*/ /*return Platillo::with('subcategoria.categoria')->get();*/ /*return Personal::with('puesto')->get()->where('puesto.nombre','=','Mesero')->get();*/ /*$posts = Personal::whereHas('puesto', function($q) { $q->where('nombre', '=', 'Mesero'); })->get(); return $posts;*/ /*return Venta::whereHas('ordenes', function($q) { $q->where('status', '=', '1'); })->with('ordenes')->get();;*/ /*return Venta::has('ordenes')->get();*/ /*return Orden::doesntHave('ventas')->where('status','=','1')->with('platillos','personal')->get();*/ /*return Orden::find('1')->with('platillos')->get();*/ return Venta::orderBy('id', 'desc')->with('ordenes.platillos')->first(); }); Route::get('wizard', function () { /*$ordenes=Orden::with('platillos')->where('status','=','')->get(); return view('verOrdenestest',compact('ordenes'));*/ return view('reportes.corteresumido'); });
public function run() { //DB::table('categorias')->delete(); // Id 1 Venta::create(array('fecha' => '2015-03-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2015-03-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2015-03-18', 'total' => '354.50', 'personal_id' => '3')); //Id 4 Venta::create(array('fecha' => '2015-03-18', 'total' => '360.38', 'personal_id' => '3')); //######################################################################################################################### //######################################################################################################################### //###################################################3##################################################################### Venta::create(array('fecha' => '2013-01-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2013-02-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2013-03-18', 'total' => '354.50', 'personal_id' => '3')); Venta::create(array('fecha' => '2013-04-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2013-05-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2013-06-18', 'total' => '354.50', 'personal_id' => '3')); Venta::create(array('fecha' => '2013-07-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2013-08-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2013-09-18', 'total' => '354.50', 'personal_id' => '3')); Venta::create(array('fecha' => '2013-10-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2013-11-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2013-12-18', 'total' => '354.50', 'personal_id' => '3')); Venta::create(array('fecha' => '2014-01-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2014-01-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2014-03-18', 'total' => '354.50', 'personal_id' => '3')); Venta::create(array('fecha' => '2014-03-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2014-05-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2015-05-18', 'total' => '354.50', 'personal_id' => '3')); Venta::create(array('fecha' => '2014-07-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2014-07-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2014-09-18', 'total' => '354.50', 'personal_id' => '3')); Venta::create(array('fecha' => '2014-09-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2014-11-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2014-11-18', 'total' => '354.50', 'personal_id' => '3')); Venta::create(array('fecha' => '2015-01-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2015-02-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2015-02-18', 'total' => '354.50', 'personal_id' => '3')); Venta::create(array('fecha' => '2015-03-18', 'total' => '1200.00', 'personal_id' => '3')); // Id 2 Venta::create(array('fecha' => '2015-03-18', 'total' => '400.00', 'personal_id' => '3')); //Id 3 Venta::create(array('fecha' => '2015-03-18', 'total' => '354.50', 'personal_id' => '3')); }
public function mejor_vendedor() { //esto retorna un json return \App\Models\Venta::mejor_vendedor(); }