diff --git a/app/Http/Controllers/Admin/ReferenceController.php b/app/Http/Controllers/Admin/ReferenceController.php new file mode 100644 index 0000000..5b1f21f --- /dev/null +++ b/app/Http/Controllers/Admin/ReferenceController.php @@ -0,0 +1,48 @@ +orderBy('sort_order')->get()->groupBy('category'); + $categories = ReferenceArticle::categories(); + return view('admin.reference.index', compact('articles','categories')); + } + public function create() { + $categories = ReferenceArticle::categories(); + return view('admin.reference.create', compact('categories')); + } + public function store(Request $r) { + $r->validate(['title'=>'required|string|max:120','category'=>'required|in:deutsch,mathe,englisch','icon'=>'required|string|max:8','content'=>'required|string']); + ReferenceArticle::create([ + 'title' => $r->title, + 'slug' => Str::slug($r->title).'-'.uniqid(), + 'category' => $r->category, + 'icon' => $r->icon, + 'content' => $r->content, + 'sort_order' => (int)$r->sort_order, + ]); + return redirect()->route('admin.reference.index')->with('success','Artikel erstellt.'); + } + public function edit(ReferenceArticle $reference) { + $categories = ReferenceArticle::categories(); + return view('admin.reference.edit', compact('reference','categories')); + } + public function update(Request $r, ReferenceArticle $reference) { + $r->validate(['title'=>'required|string|max:120','category'=>'required|in:deutsch,mathe,englisch','icon'=>'required|string|max:8','content'=>'required|string']); + $reference->update([ + 'title' => $r->title, + 'category' => $r->category, + 'icon' => $r->icon, + 'content' => $r->content, + 'sort_order' => (int)$r->sort_order, + ]); + return redirect()->route('admin.reference.index')->with('success','Gespeichert.'); + } + public function destroy(ReferenceArticle $reference) { + $reference->delete(); + return redirect()->route('admin.reference.index')->with('success','Artikel gelöscht.'); + } +} diff --git a/app/Http/Controllers/Child/ReferenceController.php b/app/Http/Controllers/Child/ReferenceController.php new file mode 100644 index 0000000..62357a8 --- /dev/null +++ b/app/Http/Controllers/Child/ReferenceController.php @@ -0,0 +1,16 @@ +get()->groupBy('category'); + $categories = ReferenceArticle::categories(); + return view('child.reference.index', compact('articles','categories')); + } + public function show(ReferenceArticle $reference) { + $others = ReferenceArticle::where('category', $reference->category) + ->where('id','!=',$reference->id)->orderBy('sort_order')->get(); + return view('child.reference.show', compact('reference','others')); + } +} diff --git a/app/Models/ReferenceArticle.php b/app/Models/ReferenceArticle.php new file mode 100644 index 0000000..9d31c26 --- /dev/null +++ b/app/Models/ReferenceArticle.php @@ -0,0 +1,9 @@ + '📖 Deutsch', 'mathe' => '🔢 Mathe', 'englisch' => '🌍 Englisch']; + } +} diff --git a/database/migrations/2026_05_05_210000_create_reference_articles_table.php b/database/migrations/2026_05_05_210000_create_reference_articles_table.php new file mode 100644 index 0000000..68164f1 --- /dev/null +++ b/database/migrations/2026_05_05_210000_create_reference_articles_table.php @@ -0,0 +1,19 @@ +id(); + $table->string('title'); + $table->string('slug')->unique(); + $table->enum('category', ['deutsch','mathe','englisch']); + $table->string('icon')->default('📖'); + $table->text('content'); + $table->unsignedSmallInteger('sort_order')->default(0); + $table->timestamps(); + }); + } + public function down(): void { Schema::dropIfExists('reference_articles'); } +}; diff --git a/resources/css/app.css b/resources/css/app.css index b5c61c9..e86bd70 100755 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -1,3 +1,18 @@ @tailwind base; @tailwind components; @tailwind utilities; + +/* Reference article content */ +.ref-content h2 { font-size:1.15rem; font-weight:700; color:#1e293b; margin:1.4rem 0 .5rem; padding-bottom:.3rem; border-bottom:2px solid #e2e8f0; } +.ref-content h3 { font-size:1rem; font-weight:600; color:#334155; margin:1rem 0 .35rem; } +.ref-content p { color:#475569; line-height:1.7; margin:.4rem 0; } +.ref-content ul, .ref-content ol { padding-left:1.4rem; margin:.4rem 0; color:#475569; } +.ref-content li { margin:.25rem 0; line-height:1.6; } +.ref-content strong { color:#1e293b; } +.ref-content .beispiel { background:#f0fdf4; border-left:3px solid #22c55e; padding:.6rem 1rem; border-radius:0 .5rem .5rem 0; margin:.6rem 0; font-size:.92rem; } +.ref-content .tipp { background:#fefce8; border-left:3px solid #eab308; padding:.6rem 1rem; border-radius:0 .5rem .5rem 0; margin:.6rem 0; font-size:.92rem; } +.ref-content .merke { background:#eff6ff; border-left:3px solid #3b82f6; padding:.6rem 1rem; border-radius:0 .5rem .5rem 0; margin:.6rem 0; font-size:.92rem; } +.ref-content table { width:100%; border-collapse:collapse; margin:.6rem 0; font-size:.9rem; } +.ref-content th { background:#f1f5f9; text-align:left; padding:.4rem .7rem; font-weight:600; color:#334155; border:1px solid #e2e8f0; } +.ref-content td { padding:.4rem .7rem; border:1px solid #e2e8f0; color:#475569; } +.ref-content tr:nth-child(even) td { background:#f8fafc; } diff --git a/resources/views/admin/reference/create.blade.php b/resources/views/admin/reference/create.blade.php new file mode 100644 index 0000000..0c54e46 --- /dev/null +++ b/resources/views/admin/reference/create.blade.php @@ -0,0 +1,47 @@ +@extends('layouts.admin') +@section('title','Neuer Artikel') +@section('content') +
+ ← Zurück +
+

Neuer Erinnerungs-Artikel

+
+ @csrf +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ +

Verfügbare Klassen: beispiel, tipp, merke als div-Klasse. Normales HTML: h2, h3, p, ul, li, strong, table.

+ +
+ +
+
+
+@endsection diff --git a/resources/views/admin/reference/edit.blade.php b/resources/views/admin/reference/edit.blade.php new file mode 100644 index 0000000..58f5580 --- /dev/null +++ b/resources/views/admin/reference/edit.blade.php @@ -0,0 +1,48 @@ +@extends('layouts.admin') +@section('title','Artikel bearbeiten') +@section('content') +
+ ← Zurück +
+

Artikel bearbeiten

+
+ @csrf @method('PUT') + @php $icon=$reference->icon; $title=$reference->title; $cat=$reference->category; $order=$reference->sort_order; $content=$reference->content @endphp +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ +

Verfügbare Klassen: beispiel, tipp, merke als div-Klasse. Normales HTML: h2, h3, p, ul, li, strong, table.

+ +
+ +
+
+
+@endsection diff --git a/resources/views/admin/reference/index.blade.php b/resources/views/admin/reference/index.blade.php new file mode 100644 index 0000000..5228989 --- /dev/null +++ b/resources/views/admin/reference/index.blade.php @@ -0,0 +1,33 @@ +@extends('layouts.admin') +@section('title','Erinnerung') +@section('content') +
+

Erinnerungs-Artikel

+ + Neuer Artikel +
+@foreach($categories as $key => $label) +@php $group = $articles->get($key, collect()) @endphp +
+

{{ $label }}

+
+ @forelse($group as $a) +
+
+ {{ $a->icon }} + {{ $a->title }} +
+
+ Bearbeiten +
+ @csrf @method('DELETE') + +
+
+
+ @empty +
Noch keine Artikel.
+ @endforelse +
+
+@endforeach +@endsection diff --git a/resources/views/child/reference/index.blade.php b/resources/views/child/reference/index.blade.php new file mode 100644 index 0000000..971cc69 --- /dev/null +++ b/resources/views/child/reference/index.blade.php @@ -0,0 +1,23 @@ +@extends('layouts.child') +@section('content') +

💡 Erinnerung

+

Hier kannst du nachschauen, was du gerade nicht mehr weißt.

+@foreach($categories as $key => $label) +@php $group = $articles->get($key, collect()) @endphp +@if($group->count()) +
+

{{ $label }}

+
+ @foreach($group as $a) + + {{ $a->icon }} + {{ $a->title }} + + + @endforeach +
+
+@endif +@endforeach +@endsection diff --git a/resources/views/child/reference/show.blade.php b/resources/views/child/reference/show.blade.php new file mode 100644 index 0000000..b944994 --- /dev/null +++ b/resources/views/child/reference/show.blade.php @@ -0,0 +1,28 @@ +@extends('layouts.child') +@section('content') +
+ ← Erinnerung +
+
+
+ {{ $reference->icon }} +

{{ $reference->title }}

+
+
+ {!! $reference->content !!} +
+
+@if($others->count()) +

Weitere Artikel

+
+ @foreach($others as $a) + + {{ $a->icon }} + {{ $a->title }} + + + @endforeach +
+@endif +@endsection diff --git a/resources/views/layouts/admin.blade.php b/resources/views/layouts/admin.blade.php index 7c730e2..41c5532 100644 --- a/resources/views/layouts/admin.blade.php +++ b/resources/views/layouts/admin.blade.php @@ -24,6 +24,7 @@ Fragen + 💡 Erinnerung 🎁 Belohnungen diff --git a/resources/views/layouts/child.blade.php b/resources/views/layouts/child.blade.php index 2393ba3..139eb4a 100644 --- a/resources/views/layouts/child.blade.php +++ b/resources/views/layouts/child.blade.php @@ -14,6 +14,7 @@
Lernen 🪙 Belohnungen + 💡 Erinnerung
🪙 {{ auth()->user()->points }}
diff --git a/routes/web.php b/routes/web.php index a4c3e19..d0a501f 100755 --- a/routes/web.php +++ b/routes/web.php @@ -21,6 +21,7 @@ Route::middleware(['auth','admin'])->prefix('admin')->name('admin.')->group(func Route::post('questions/import', [Admin\QuestionController::class,'import'])->name('questions.import'); Route::resource('questions',Admin\QuestionController::class); Route::resource('rewards', Admin\RewardController::class)->except('show'); + Route::resource('reference', Admin\ReferenceController::class)->except('show'); Route::get ('redemptions', [Admin\RedemptionController::class,'index']) ->name('redemptions.index'); Route::patch ('redemptions/{redemption}/approve', [Admin\RedemptionController::class,'approve'])->name('redemptions.approve'); Route::patch ('redemptions/{redemption}/reject', [Admin\RedemptionController::class,'reject']) ->name('redemptions.reject'); @@ -33,6 +34,8 @@ Route::middleware(['auth','child'])->group(function () { Route::post('lernen/{subject:slug}/antwort', [\App\Http\Controllers\Child\LearnController::class,'answer']) ->name('learn.answer'); Route::get ('belohnungen', [\App\Http\Controllers\Child\RewardController::class,'index']) ->name('rewards.index'); Route::post('belohnungen/{reward}/einloesen', [\App\Http\Controllers\Child\RewardController::class,'redeem']) ->name('rewards.redeem'); + Route::get ('erinnerung', [\App\Http\Controllers\Child\ReferenceController::class,'index'])->name('reference.index'); + Route::get ('erinnerung/{reference:slug}', [\App\Http\Controllers\Child\ReferenceController::class,'show']) ->name('reference.show'); }); require __DIR__.'/auth.php';