public function getDashboard() { $lastWeek = Carbon::now()->subWeek(); $lastMonth = Carbon::now()->subMonth(); //return $today; $todaySales = DB::table('stores')->rightJoin('customers', 'stores.id', '=', 'customers.store_id')->whereRaw('date(customers.created_at) >= date("' . Carbon::today() . '")')->sum('cost'); $allSales = DB::table('stores')->rightJoin('customers', 'stores.id', '=', 'customers.store_id')->sum('cost'); $weekSales = DB::table('stores')->rightJoin('customers', 'stores.id', '=', 'customers.store_id')->whereRaw('customers.created_at >= date("' . $lastWeek . '")')->sum('cost'); $monthSales = DB::table('stores')->rightJoin('customers', 'stores.id', '=', 'customers.store_id')->whereRaw('customers.created_at >= date("' . $lastMonth . '")')->sum('cost'); $todayCustomers = DB::table('customers')->whereRaw('date(customers.created_at) >= date("' . Carbon::today() . '")')->count(); $allCustomers = DB::table('customers')->count(); $weekCustomers = DB::table('customers')->whereRaw('customers.created_at >= date("' . $lastWeek . '")')->count(); $monthCustomers = DB::table('customers')->whereRaw('customers.created_at >= date("' . $lastMonth . '")')->count(); $weekData = DB::table('stores')->rightJoin('customers', 'stores.id', '=', 'customers.store_id')->select(array(DB::Raw('sum(stores.cost) as saleCount'), DB::Raw('count(customers.id) as customerCount'), DB::Raw('DATE(customers.created_at) day')))->whereRaw('customers.created_at >= date("' . $lastWeek . '")')->groupBy('day')->orderBy('day')->get(); //return $weekCount; $customers = Customer::with('Store')->whereRaw('date(customers.created_at) >= date("' . Carbon::today() . '")')->orderBy('created_at')->get(); // return $customers; $output = ['customers' => $customers, 'todaySales' => $todaySales, 'allSales' => $allSales, 'weekSales' => $weekSales, 'monthSales' => $monthSales, 'todayCustomers' => $todayCustomers, 'allCustomers' => $allCustomers, 'weekCustomers' => $weekCustomers, 'monthCustomers' => $monthCustomers, 'activeStores' => Store::where('is_active', true)->count(), 'allStores' => Store::all()->count(), 'weekData' => $weekData]; //return $output; return view('admin.dashboard', $output); }
/** * Run the database seeds. * * @return void */ public function run() { $item1 = ItemInfo::create(['name' => 'lucky charms']); $item2 = ItemInfo::create(['name' => 'chicken']); $item3 = ItemInfo::create(['name' => 'coke']); $item4 = ItemInfo::create(['name' => 'frozen pizza']); $item5 = ItemInfo::create(['name' => 'sprite']); $item6 = ItemInfo::create(['name' => 'pepsi']); $item7 = ItemInfo::create(['name' => 'mtn dew']); $item8 = ItemInfo::create(['name' => 'crackers']); $item9 = ItemInfo::create(['name' => 'breakfast bar']); $item10 = ItemInfo::create(['name' => 'shrimp']); $item11 = ItemInfo::create(['name' => 'hot dogs']); $item12 = ItemInfo::create(['name' => 'hot dog buns']); $item13 = ItemInfo::create(['name' => 'mustard']); $item14 = ItemInfo::create(['name' => 'pickle']); $item15 = ItemInfo::create(['name' => 'banana']); $item16 = ItemInfo::create(['name' => 'apple']); $item17 = ItemInfo::create(['name' => 'bacon']); $item18 = ItemInfo::create(['name' => 'hot pocket']); $item19 = ItemInfo::create(['name' => 'orange juice']); $item20 = ItemInfo::create(['name' => 'candy']); $items = [$item1, $item2, $item3, $item4, $item5, $item6, $item7, $item8, $item9, $item10, $item11, $item12, $item13, $item14, $item15, $item16, $item17, $item18, $item19, $item20]; $stores = Store::all(); /* Generate these 4 items for each store with random prices between $1.00 and $6.00 (100 - 600 in DB) */ foreach ($stores as $store) { foreach ($items as $item) { $i = new Item(); $i->price = rand(100, 600); $i->store()->associate($store); $i->itemInfo()->associate($item); $i->save(); } } }
/** * Display a listing of the resource. * * @return Response */ public function index() { $stores = Store::all(); return view('admin.stores.index', compact('stores')); }
function get_index() { return Store::all()->toJson(); }
public function getStores() { return Store::all(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return view('stores.index', ['stores' => Store::all()]); }
public function updateItems() { foreach (Store::all() as $store) { $total_volume = 0; foreach ($store->stock_items as $item) { $total_volume += $item->amount * 0.001 * $item->packaging->cm_per_dose; } $store->used_volume = $total_volume; $store->save(); } }
public function stores() { $stores = Store::all(); return view('store.index', compact('stores')); }
public function getList() { $r = Request::all(); $sortColumn = $r['columns'][$r['order'][0]['column']]['data']; $sortOrder = $r['order'][0]['dir']; $searchValue = '%' . $r['search']['value'] . '%'; $products = Store::all(); $filtered = Store::where('name', 'LIKE', $searchValue)->orWhere('description', 'LIKE', $searchValue)->orWhere('phone', 'LIKE', $searchValue)->orderBy($sortColumn, $sortOrder); return ['draw' => $r['draw'], 'recordsTotal' => count($filtered->get()), 'recordsFiltered' => count($filtered->get()), 'data' => $filtered->limit($r['length'])->offset($r['start'])->get()]; }
public function stores($id) { $audit = Audit::findOrFail($id); $stores = Store::all(); return view('audit.show', compact('audit', 'stores')); }
public function index() { $stores = \App\Store::all(); return response()->json($stores); }