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

42 lines
763 B
PHP

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