コード例 #1
0
ファイル: DashboardController.php プロジェクト: poudigne/lcdj
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $first = date('Y-m-d', mktime(0, 0, 0, date('m'), 1, date('Y')));
     $last = date('Y-m-t', mktime(0, 0, 0, date('m'), 1, date('Y')));
     $inventory_value = Inventory::select(DB::Raw('SUM(products.cost_price * inventories.quantity) as total_value'))->join('products', 'products.id', '=', 'inventories.product_id')->get();
     $top_product = Sale::select('products.title', 'sales.product_id', DB::raw('count(sales.product_id) as sales_count'))->join('products', 'products.id', '=', 'sales.product_id')->whereBetween('sales.created_at', array($first, $last))->groupBy('sales.product_id')->orderBy('sales_count', 'desc')->take(10)->get();
     return view('dashboard/dashboard')->with('top_product', $top_product)->with('total_value', $inventory_value);
 }
コード例 #2
0
ファイル: Sale.php プロジェクト: tailehuu/laravel-crm
 static function getCustomerName()
 {
     $customerNames = Sale::select('customer_name')->distinct()->groupBy('customer_name')->get();
     return $customerNames;
 }