feat: Add user level and experience attributes, and implement reward, task, and quest models with corresponding controllers and migrations
This commit is contained in:
parent
aa50740dcb
commit
fd20278948
17 changed files with 963 additions and 112 deletions
25
backend/app/Http/Controllers/UserController.php
Normal file
25
backend/app/Http/Controllers/UserController.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Reward;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function status(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
$xpForNextLevel = $user->level * 100;
|
||||
|
||||
// Finde noch nicht freigeschaltete Rewards, die in Reichweite sind
|
||||
$upcomingRewards = Reward::where('unlocked_at_level', '>', $user->level)->limit(5)->get();
|
||||
|
||||
return response()->json([
|
||||
'level' => $user->level,
|
||||
'xp' => $user->xp,
|
||||
'xp_for_next_level' => $xpForNextLevel,
|
||||
'upcoming_rewards' => $upcomingRewards
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue