Fix increment
This commit is contained in:
@@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
||||
use App\Models\ShitUser;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
|
||||
class ShitController extends Controller
|
||||
{
|
||||
@@ -21,7 +22,7 @@ class ShitController extends Controller
|
||||
$lastshit = ShitUser::where('user_id', $shituser->user_id)->orderByDesc('created_at')->first();
|
||||
|
||||
$timethreshold = Carbon::now()->subMinutes(10);
|
||||
if ($lastshit->created_at->lessThan($timethreshold)) {
|
||||
if (is_null($lastshit) || $lastshit->created_at->lessThan($timethreshold)) {
|
||||
$shituser->save();
|
||||
return redirect('/ownstats');
|
||||
} else {
|
||||
@@ -42,4 +43,10 @@ class ShitController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function highscores() {
|
||||
|
||||
$allshits = ShitUser::groupBy('user_id')->select('user_id', DB::raw('count (*) as total'))->get();
|
||||
dd($allshits);
|
||||
}
|
||||
|
||||
}
|
||||
|
41
shit-show/resources/views/highscores.blade.php
Normal file
41
shit-show/resources/views/highscores.blade.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<x-app-layout>
|
||||
<!--<x-slot name="header">
|
||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||
{{-- __('Dashboard') --}}
|
||||
</h2>
|
||||
</x-slot>-->
|
||||
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">First</th>
|
||||
<th scope="col">Last</th>
|
||||
<th scope="col">Handle</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">1</th>
|
||||
<td>Mark</td>
|
||||
<td>Otto</td>
|
||||
<td>@mdo</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">2</th>
|
||||
<td>Jacob</td>
|
||||
<td>Thornton</td>
|
||||
<td>@fat</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">3</th>
|
||||
<td colspan="2">Larry the Bird</td>
|
||||
<td>@twitter</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</x-app-layout>
|
@@ -25,5 +25,6 @@ Route::get('/dashboard', function () {
|
||||
|
||||
Route::post('/increment', [ShitController::class, 'increment'])->middleware(['auth']);
|
||||
Route::get('/ownstats', [ShitController::class, 'ownStats'])->middleware(['auth']);
|
||||
Route::get('/highscores', [ShitController::class, 'highscores'])->middleware(['auth']);
|
||||
|
||||
require __DIR__.'/auth.php';
|
||||
|
Reference in New Issue
Block a user