Refactor UserController + Add logic index & show

This commit is contained in:
NoAvatar 2024-10-17 06:26:41 +10:00
parent 3e0ce34468
commit c37c37d6e5

View File

@ -2,52 +2,40 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class UserController extends Controller class UserController extends Controller
{ {
/** // GET /user
* Display a listing of the resource.
*/
public function index() public function index()
{ {
// return response(User::all());
return response("Get all users");
} }
/** // GET /user/{id}
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
return response("User store with data: " . $request->json());
}
/**
* Display the specified resource.
*/
public function show(string $id) public function show(string $id)
{ {
// $user = User::query()->findOrFail('id', $id);
return response("User with id " . $id);
return response($user);
} }
/** // POST /user
* Update the specified resource in storage. public function store(Request $request)
*/ {
return response("Create user");
}
// PUT /user/{id}
public function update(Request $request, string $id) public function update(Request $request, string $id)
{ {
//
return response("Update user " . $id); return response("Update user " . $id);
} }
/** // DELETE /user/{id}
* Remove the specified resource from storage.
*/
public function destroy(string $id) public function destroy(string $id)
{ {
//
return response("Destroy user " . $id); return response("Destroy user " . $id);
} }
} }