From e0efb6a5d71edaa28e3948d018d75e88d4234063 Mon Sep 17 00:00:00 2001 From: shihab Date: Sat, 25 Jun 2022 15:36:13 +0600 Subject: [PATCH] uddate controller methods doc --- app/Http/Controllers/RoleController.php | 4 ++-- app/Http/Controllers/UserController.php | 18 ++++++++++++------ app/Http/Controllers/UserRoleController.php | 8 ++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/RoleController.php b/app/Http/Controllers/RoleController.php index 27be130..b78b6be 100644 --- a/app/Http/Controllers/RoleController.php +++ b/app/Http/Controllers/RoleController.php @@ -44,7 +44,7 @@ class RoleController extends Controller { * Display the specified resource. * * @param \App\Models\Role $role - * @return \Illuminate\Http\Response + * @return \App\Models\Role $role */ public function show(Role $role) { return $role; @@ -55,7 +55,7 @@ class RoleController extends Controller { * * @param \Illuminate\Http\Request $request * @param \App\Models\Role $role - * @return \Illuminate\Http\Response + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|Role */ public function update(Request $request, Role $role = null) { diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 7c110e5..8b81143 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -17,7 +17,6 @@ class UserController extends Controller { * @return \Illuminate\Http\Response */ public function index() { - // return User::all(); } @@ -76,7 +75,7 @@ class UserController extends Controller { } $roles = $user->roles->pluck('slug')->all(); - + $plainTextToken = $user->createToken('hydra-api-token', $roles)->plainTextToken; return response(['error' => 0, 'id' => $user->id, 'token' => $plainTextToken], 200); } @@ -85,7 +84,7 @@ class UserController extends Controller { * Display the specified resource. * * @param \App\Models\User $user - * @return \Illuminate\Http\Response + * @return \App\Models\User $user */ public function show(User $user) { return $user; @@ -94,9 +93,10 @@ class UserController extends Controller { /** * Update the specified resource in storage. * - * @param \Illuminate\Http\Request $request - * @param \App\Models\User $user - * @return \Illuminate\Http\Response + * @param \Illuminate\Http\Request $request + * @param \App\Models\User $user + * @return User + * @throws MissingAbilityException */ public function update(Request $request, User $user) { $user->name = $request->name ?? $user->name; @@ -143,6 +143,12 @@ class UserController extends Controller { return response(['error' => 0, 'message' => 'user deleted']); } + /** + * Return Auth user + * + * @param Request $request + * @return mixed + */ public function me(Request $request) { return $request->user(); } diff --git a/app/Http/Controllers/UserRoleController.php b/app/Http/Controllers/UserRoleController.php index 9992fb0..b3b9f0e 100644 --- a/app/Http/Controllers/UserRoleController.php +++ b/app/Http/Controllers/UserRoleController.php @@ -11,7 +11,7 @@ class UserRoleController extends Controller { * Display a listing of the resource. * * @param \App\Models\User $user - * @return \Illuminate\Http\Response + * @return \App\Models\User $user */ public function index(User $user) { return $user->load('roles'); @@ -22,7 +22,7 @@ class UserRoleController extends Controller { * * @param \Illuminate\Http\Request $request * @param \App\Models\User $user - * @return \Illuminate\Http\Response + * @return \App\Models\User $user */ public function store(Request $request, User $user) { $data = $request->validate([ @@ -32,7 +32,7 @@ class UserRoleController extends Controller { if (!$user->roles()->find($data['role_id'])) { $user->roles()->attach($role); } - + return $user->load('roles'); } @@ -41,7 +41,7 @@ class UserRoleController extends Controller { * * @param \App\Models\User $user * @param \App\Models\Role $role - * @return \Illuminate\Http\Response + * @return \App\Models\User $user */ public function destroy(User $user, Role $role) { $user->roles()->detach($role);