middleware(['auth', 'verified', '2fa']); } /** * Show the application dashboard. * * @param $attraction_id * @return \Illuminate\Contracts\Support\Renderable */ public function index($attraction_id) { $name = DB::table('attraction')->select('name')->where('id', '=', $attraction_id)->first()->name; $top10 = DB::table(DB::raw('ridecount, (SELECT @row_number:=0) AS t'))->select('uuid', DB::raw('SUM(`count`) AS `count`'), DB::raw('(@row_number:=@row_number + 1) AS `num`')) ->where('attractionId', '=', $attraction_id) ->whereRaw('YEARWEEK(date, 1) = YEARWEEK(CURDATE(), 1)') ->whereRaw('YEAR(date) = YEAR(CURDATE())') ->groupBy('uuid') ->orderByDesc('count') ->take(10)->get()->all(); $personal = DB::table('ridecount') ->where('attractionId', '=', $attraction_id) ->where('uuid', '=', Auth::user()->uuid) ->sum('count'); $total = DB::table('ridecount') ->where('attractionId', '=', $attraction_id) ->sum('count'); return view('ridecount')->with([ 'name' => $name, 'top10' => $top10, 'personal' => $personal, 'total' => $total ]); } }