3
0
Fork 0

Redesign + Fixes

This commit is contained in:
thomas 2021-06-29 22:05:00 +02:00
parent 7718ed6c32
commit 7fe8056e35
67 changed files with 1898 additions and 2799 deletions

View file

@ -26,26 +26,57 @@ class RidecountController extends Controller
*/
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')
$attraction = DB::table('attractions')->select(['cover','name','status_id'])->where('id', '=', $attraction_id)->first();
if(empty($attraction))
return redirect()->route('status');
$type = env('TOP', 1);
if($type < 0 || $type > 4)
return redirect()->route('status');
switch ($type) {
case 1:
$filter = 'week = WEEK(CURDATE(), 1)';
break;
case 2:
$filter = 'month = MONTH(CURDATE())';
break;
case 3:
$filter = 0;
break;
case 4:
$filter = -1;
break;
default:
$filter = 'day = DAYOFYEAR(CURDATE())';
break;
}
$top10 = DB::table(DB::raw('ridecounts, (SELECT @row_number:=0) AS t'))->select('uuid', DB::raw('SUM(`count`) AS `count`'), DB::raw('(@row_number:=@row_number + 1) AS `num`'))
->where('attraction_id', '=', $attraction_id);
if(!empty($filter))
$top10 = $top10->whereRaw($filter);
if($filter !== -1)
$top10 = $top10->whereRaw('year = YEAR(CURDATE())');
$top10 = $top10->groupBy('uuid')
->orderByDesc('count')
->take(10)->get()->all();
$personal = DB::table('ridecount')
->where('attractionId', '=', $attraction_id)
->where('uuid', '=', Auth::user()->uuid)
$personal = DB::table('ridecounts')
->where('attraction_id', '=', $attraction_id)
->where('uuid', '=', Auth::user()->fixedUUID())
->sum('count');
$total = DB::table('ridecount')
->where('attractionId', '=', $attraction_id)
$total = DB::table('ridecounts')
->where('attraction_id', '=', $attraction_id)
->sum('count');
$attraction->status = DB::table('states')->where('id', '=', $attraction->status_id)->first();
return view('ridecount')->with([
'name' => $name,
'attraction' => $attraction,
'top10' => $top10,
'personal' => $personal,
'total' => $total