DashboardUtil = $DashboardUtil; DB::enableQueryLog(); } public function index() { $reguler_points = User::select('users.name', DB::raw('SUM(point_logs.point) as total_point'))->rightJoin('point_logs', 'point_logs.user_id', 'users.id')->where('event_id', '=', 0)->groupBy('point_logs.user_id')->orderBy('total_point', 'desc')->limit(5)->get(); $reguler_point_all = []; $reguler_user_all = []; foreach($reguler_points as $key => $value){ array_push($reguler_point_all , intval($value->total_point)); array_push($reguler_user_all , $value->name); } $event_points = User::select('users.name', DB::raw('SUM(point_logs.point) as total_point'))->rightJoin('point_logs', 'point_logs.user_id', 'users.id')->where('event_id', '=', 1)->groupBy('point_logs.user_id')->orderBy('total_point', 'desc')->limit(5)->get(); $event_point_all = []; $event_user_all = []; foreach($event_points as $key => $value){ array_push($event_point_all , intval($value->total_point)); array_push($event_user_all , $value->name); } $data = [ //bawaan 'title' => $this->title, 'route' => $this->route, 'reguler_user_all' => $reguler_user_all, 'reguler_point_all' => $reguler_point_all, 'event_user_all' => $event_user_all, 'event_point_all' => $event_point_all, ]; // dd($data['log_points']); return view($this->route . 'index', $data); } }