Add own stats site
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ShitUser;
|
||||
use Auth;
|
||||
|
||||
class ShitController extends Controller
|
||||
{
|
||||
@@ -11,10 +12,26 @@ class ShitController extends Controller
|
||||
public function increment(Request $request) {
|
||||
$shituser = new ShitUser();
|
||||
|
||||
$shituser->user_id = Auth::user()->id;
|
||||
$shituser->description = $request->description;
|
||||
$shituser->goldenshit = $request->goldenshit == "on";
|
||||
|
||||
$shituser->save();
|
||||
|
||||
return redirect('/dashboard');
|
||||
|
||||
}
|
||||
|
||||
public function ownStats() {
|
||||
|
||||
$shits = ShitUser::where('user_id', Auth::user()->id)->get();
|
||||
$amountshits = $shits->count();
|
||||
$goldenshits = $shits->where('goldenshit', true)->count();
|
||||
|
||||
return view('ownstats')->with([
|
||||
'amountshits' => $amountshits,
|
||||
'goldenshits' => $goldenshits,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,13 +13,15 @@ class ShitUser extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('shituser', function (Blueprint $table) {
|
||||
Schema::create('shit_users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->index('user_id');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
$table->string('description');
|
||||
$table->string('description')->nullable();
|
||||
$table->boolean('goldenshit');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -5,9 +5,27 @@
|
||||
</h2>
|
||||
</x-slot>-->
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<h1>Shit-Show Login Bereich</h1>
|
||||
<div class="p-5 mb-4 bg-light rounded-3">
|
||||
<div class="container-fluid py-5">
|
||||
<h1 class="display-5 fw-bold">Stuhlgang hinzufügen</h1>
|
||||
<p class="col-md-8 fs-4">Mit einem Knopfdruck wird ein weiterer Stuhlgang hinzugefügt. Sie dürfen im folgenden Textfeld gerne noch Details in schriftlicher Form beisteuern.</p>
|
||||
<form action="/increment" method="post">
|
||||
@csrf
|
||||
<div class="col-sm-6">
|
||||
<label for="description" class="form-label">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="description" placeholder="Beschreibungstext hier einfügen..." value="">
|
||||
<div class="invalid-feedback">
|
||||
Ungültige Beschreibung.
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="goldenshit" name="goldenshit">
|
||||
<label class="form-check-label" for="goldenshit">Mein Stuhlgang war ein goldener Schiss.</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-lg">Plop!</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@@ -7,7 +7,8 @@
|
||||
|
||||
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
|
||||
<li><a href="/" class="nav-link px-2 text-secondary">Shit-Show</a></li>
|
||||
<li><a href="/dashboard" class="nav-link px-2 text-white">Highscores</a></li>
|
||||
<li><a href="/dashboard" class="nav-link px-2 text-white">Dashboard</a></li>
|
||||
<li><a href="/ownstats" class="nav-link px-2 text-white">Eigene Statistik</a></li>
|
||||
<li><a href="/" class="nav-link px-2 text-white">Highscores</a></li>
|
||||
<li><a href="/" class="nav-link px-2 text-white">Preise</a></li>
|
||||
<li><a href="/" class="nav-link px-2 text-white">FAQ</a></li>
|
||||
|
@@ -15,8 +15,12 @@
|
||||
|
||||
|
||||
<div class="text-end">
|
||||
@auth
|
||||
<a href="/dashboard"><button type="button" class="btn btn-outline-light me-2">Dashboard anzeigen</button></a>
|
||||
@else
|
||||
<a href="/login"><button type="button" class="btn btn-outline-light me-2">Login</button></a>
|
||||
<a href="/register"><button type="button" class="btn btn-warning">Registrieren</button></a>
|
||||
@endauth
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
18
shit-show/resources/views/ownstats.blade.php
Normal file
18
shit-show/resources/views/ownstats.blade.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<x-app-layout>
|
||||
<!--<x-slot name="header">
|
||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||
{{-- __('Dashboard') --}}
|
||||
</h2>
|
||||
</x-slot>-->
|
||||
|
||||
|
||||
<div class="p-5 mb-4 bg-light rounded-3">
|
||||
<div class="container-fluid py-5">
|
||||
<h1 class="display-5 fw-bold">Ihre Stuhlgänge</h1>
|
||||
<p class="col-md-8 fs-4">Sie haben ingesamt {{ $amountshits }} Stuhlgänge erreicht, davon sind {{ $goldenshits }} goldene Stuhlgänge.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</x-app-layout>
|
@@ -23,6 +23,7 @@ Route::get('/dashboard', function () {
|
||||
return view('dashboard');
|
||||
})->middleware(['auth'])->name('dashboard');
|
||||
|
||||
Route::get('/increment', [ShitController::class, 'increment']);
|
||||
Route::post('/increment', [ShitController::class, 'increment'])->middleware(['auth']);
|
||||
Route::get('/ownstats', [ShitController::class, 'ownStats'])->middleware(['auth']);
|
||||
|
||||
require __DIR__.'/auth.php';
|
||||
|
Reference in New Issue
Block a user