feat: Lernapp mit Mathe/Deutsch/Englisch, Münzsystem und Belohnungen
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Reward;
|
||||
use Illuminate\Http\Request;
|
||||
class RewardController extends Controller {
|
||||
public function index() {
|
||||
$rewards = Reward::orderBy('points_cost')->get();
|
||||
return view('admin.rewards.index', compact('rewards'));
|
||||
}
|
||||
public function create() { return view('admin.rewards.create'); }
|
||||
public function store(Request $r) {
|
||||
$r->validate([
|
||||
'name' => 'required|string|max:80',
|
||||
'description' => 'nullable|string|max:200',
|
||||
'icon' => 'required|string|max:10',
|
||||
'points_cost' => 'required|integer|min:1',
|
||||
'minutes' => 'nullable|integer|min:1',
|
||||
]);
|
||||
Reward::create(array_merge($r->only('name','description','icon','points_cost','minutes'), ['active'=>true]));
|
||||
return redirect()->route('admin.rewards.index')->with('success','Belohnung erstellt.');
|
||||
}
|
||||
public function edit(Reward $reward) { return view('admin.rewards.edit', compact('reward')); }
|
||||
public function update(Request $r, Reward $reward) {
|
||||
$r->validate([
|
||||
'name' => 'required|string|max:80',
|
||||
'description' => 'nullable|string|max:200',
|
||||
'icon' => 'required|string|max:10',
|
||||
'points_cost' => 'required|integer|min:1',
|
||||
'minutes' => 'nullable|integer|min:1',
|
||||
]);
|
||||
$reward->update(array_merge(
|
||||
$r->only('name','description','icon','points_cost','minutes'),
|
||||
['active' => $r->boolean('active', true)]
|
||||
));
|
||||
return redirect()->route('admin.rewards.index')->with('success','Gespeichert.');
|
||||
}
|
||||
public function destroy(Reward $reward) {
|
||||
$reward->delete();
|
||||
return redirect()->route('admin.rewards.index')->with('success','Belohnung gelöscht.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user