<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class UserController extends Controller
{
    public function index(Request $request): JsonResponse
    {
        $user = $request->user()->load('user_group');

        return $this->success($user);
    }

    public function update(Request $request): JsonResponse
    {
        $user = $request->user('sanctum');

        $user->update($request->only(['name']));

        return $this->success($user);
    }
}
