laravel-api-simple-blog/app/Http/Controllers/UserController.php

42 lines
769 B
PHP
Raw Normal View History

2024-10-16 21:53:02 +03:00
<?php
namespace App\Http\Controllers;
use App\Models\User;
2024-10-16 21:53:02 +03:00
use Illuminate\Http\Request;
class UserController extends Controller
{
// GET /user
2024-10-16 21:53:02 +03:00
public function index()
{
return response(User::all());
2024-10-16 21:53:02 +03:00
}
// GET /user/{id}
public function show(string $id)
2024-10-16 21:53:02 +03:00
{
$user = User::query()->findOrFail('id', $id);
return response($user);
2024-10-16 21:53:02 +03:00
}
// POST /user
public function store(Request $request)
2024-10-16 21:53:02 +03:00
{
return response("Create user");
2024-10-16 21:53:02 +03:00
}
// PUT /user/{id}
2024-10-16 21:53:02 +03:00
public function update(Request $request, string $id)
{
return response("Update user " . $id);
}
// DELETE /user/{id}
2024-10-16 21:53:02 +03:00
public function destroy(string $id)
{
return response("Destroy user " . $id);
}
}