File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 11<?php
22
3- use Illuminate \Http \ Request ;
3+ use Illuminate \Support \ Facades \ Auth ;
44use Illuminate \Support \Facades \Route ;
55use App \Http \Controllers \TokenController ;
66use App \Http \Controllers \AvatarController ;
7+ use App \Http \Resources \UserResource ;
78use App \Models \User ;
89
910/*
2021Route::post ('/sanctum/token ' , TokenController::class);
2122
2223Route::middleware (['auth:sanctum ' ])->group (function () {
23- Route::get ('/users/{user} ' , function (Request $ request ) {
24- return $ request -> user ();
24+ Route::get ('/users/auth ' , function () {
25+ return new UserResource (Auth:: user () );
2526 });
2627
27- Route::get ('/users ' , function () {
28- return User::all ( );
28+ Route::get ('/users/{id} ' , function ($ id ) {
29+ return new UserResource ( User::findOrFail ( $ id ) );
2930 });
3031
31- Route::get ('/users/auth ' , function () {
32- return auth ()-> user ( );
32+ Route::get ('/users ' , function () {
33+ return UserResource:: collection (User:: paginate () );
3334 });
3435
3536 Route::post ('/users/auth/avatar ' , [AvatarController::class, 'store ' ]);
You can’t perform that action at this time.
0 commit comments