Refactor UserController + Add logic index & show
This commit is contained in:
parent
3e0ce34468
commit
c37c37d6e5
@ -2,52 +2,40 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
// GET /user
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
return response("Get all users");
|
||||
return response(User::all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
return response("User store with data: " . $request->json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
// GET /user/{id}
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
return response("User with id " . $id);
|
||||
$user = User::query()->findOrFail('id', $id);
|
||||
|
||||
return response($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
// 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
// DELETE /user/{id}
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
return response("Destroy user " . $id);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user