Dashboard history

This commit is contained in:
2021-12-27 11:59:50 +01:00
parent 34d44011bd
commit 2d23f5da59
3 changed files with 34 additions and 5 deletions

View File

@@ -12,6 +12,17 @@ use DB;
class ShitController extends Controller class ShitController extends Controller
{ {
public function dashboard() {
$allshits = ShitUser::all()->sortByDesc('created_at')->take(100);
$buttonRand = collect(['Plop!', 'Pflomp!', 'Zwusch!', 'Blomp!'])->random();
return view('dashboard')->with([
'allshits' => $allshits,
'buttonRand' => $buttonRand,
]);
}
public function increment(Request $request) { public function increment(Request $request) {
$shituser = new ShitUser(); $shituser = new ShitUser();

View File

@@ -14,7 +14,7 @@
@csrf @csrf
<div class="col-sm-6"> <div class="col-sm-6">
<label for="description" class="form-label">Beschreibung</label> <label for="description" class="form-label">Beschreibung</label>
<input type="text" class="form-control" id="description" placeholder="Beschreibungstext hier einfügen..." value=""> <input type="text" class="form-control" id="description" name="description" placeholder="Beschreibungstext hier einfügen..." value="">
<div class="invalid-feedback"> <div class="invalid-feedback">
Ungültige Beschreibung. Ungültige Beschreibung.
</div> </div>
@@ -23,10 +23,30 @@
<input type="checkbox" class="form-check-input" id="goldenshit" name="goldenshit"> <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> <label class="form-check-label" for="goldenshit">Mein Stuhlgang war ein goldener Schiss.</label>
</div> </div>
<button type="submit" class="btn btn-primary btn-lg">Plop!</button> <button type="submit" class="btn btn-primary btn-lg">{{ $buttonRand }}</button>
</form> </form>
</div> </div>
</div> </div>
<div class="container-fluid">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Zeit</th>
<th scope="col">Beschreibung</th>
<th scope="col">Goldener Schiss</th>
</tr>
</thead>
<tbody>
@foreach($allshits as $shit)
<tr>
<th scope="row">{{ $shit->created_at }}</th>
<td>{{ $shit->description }} </td>
<td>{{ $shit->goldenshit ? "Ja" : "Nein" }} </td>
</tr>
@endforeach
</tbody>
</table>
</div>
</x-app-layout> </x-app-layout>

View File

@@ -19,9 +19,7 @@ Route::get('/', function () {
return view('welcome'); return view('welcome');
}); });
Route::get('/dashboard', function () { Route::get('/dashboard', [ShitController::class, 'dashboard'])->middleware(['auth'])->name('dashboard');
return view('dashboard');
})->middleware(['auth'])->name('dashboard');
Route::post('/increment', [ShitController::class, 'increment'])->middleware(['auth']); Route::post('/increment', [ShitController::class, 'increment'])->middleware(['auth']);
Route::get('/ownstats', [ShitController::class, 'ownStats'])->middleware(['auth']); Route::get('/ownstats', [ShitController::class, 'ownStats'])->middleware(['auth']);