54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class RidecountController extends Controller
|
|
{
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->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)')
|
|
->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
|
|
]);
|
|
}
|
|
|
|
}
|