Kész lábléc, javított hozzáadás és login elkezdve

This commit is contained in:
Sándor Máté Magony
2025-04-09 10:42:43 +02:00
parent cc7c8bc8dd
commit 2975cd91b1
4 changed files with 109 additions and 4 deletions

View File

@@ -2,13 +2,74 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Http\Request;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
return response()->json(User::all());
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$validatedData = $request -> validate([
'nev' => 'requierd|string',
'email' => 'requierd|email',
'felh_nev' => 'requierd|string',
'jelszo' => 'requierd|password',
'is_admin' => 'required|boolean'
]);
try {
$felhasznalo = User::create([
'nev' => $validatedData['nev'],
'email' => $validatedData['email'],
'felh_nev' => $validatedData['felh_nev'],
'jelszo' => $validatedData['jelszo'],
'is_admin' => $validatedData['is_admin']
]);
return response() -> json([
'message' => 'Sikeres rögzítés',
'data' => $felhasznalo
], 201);
} catch (\Exception $e) {
return response() -> json([
'message' => 'Hiba történt a mentés során',
'error' => $e -> getMessage()
], 500);
}
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}