Conversation
| $this->middleware('auth'); | ||
| } | ||
|
|
||
| public function profile($id){ |
There was a problem hiding this comment.
PSR coding style violation.
{ should be on the next line.
There was a problem hiding this comment.
Fix it in other places too.
| } | ||
|
|
||
| public function profile($id){ | ||
| $user = User::where('id',$id)->first(); |
There was a problem hiding this comment.
PSR coding style violation.
where('id',$id), there should be a space after comma, like this: where('id', $id)
There was a problem hiding this comment.
Fix it in other places too.
| $this->middleware('auth'); | ||
| } | ||
|
|
||
| public function profile($id){ |
There was a problem hiding this comment.
Rather than passing an id and querying to find the user with that id, just bind Route model here.
| } | ||
|
|
||
| public function profileUpdate(Request $request){ | ||
| $validator = Validator::make($request->all(),[ |
There was a problem hiding this comment.
Don't write validation logic here. Create separate Request file with validation logic.
| $profile->name=$request->name; | ||
| $profile->email=$request->email; | ||
| if($request->filled('password')){ | ||
| dd('test'); |
There was a problem hiding this comment.
non-functioning, broken code.
| return redirect()->back()->with('success','nothing updated'); | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Remove redundant empty lines.
| $profile->password=$request->password; | ||
| } | ||
| $profile->update(); | ||
| if($profile->wasChanged()){ |
There was a problem hiding this comment.
No need to have this check.
| <div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center"> | ||
| <a class="navbar-brand brand-logo mr-5" href="index.html"><img src="images/logo.svg" class="mr-2" alt="logo"/></a> | ||
| <a class="navbar-brand brand-logo-mini" href="index.html"><img src="images/logo-mini.svg" alt="logo"/></a> | ||
| <a class="navbar-brand brand-logo mr-5" href="index.html"><img src="{{asset('asset')}}/images/logo.svg" class="mr-2" alt="logo"/></a> |
There was a problem hiding this comment.
The whole image path should be inside asset method.
| })->middleware(['auth'])->name('dashboard'); | ||
|
|
||
| Route::get('profile/{id}',[UserController::class,'profile'])->name('profile'); | ||
| Route::put('profile-update',[UserController::class,'profileUpdate'])->name('profile-update'); |
There was a problem hiding this comment.
The route should be profile/update.
| return view('admin.dashboard'); | ||
| })->middleware(['auth'])->name('dashboard'); | ||
|
|
||
| Route::get('profile/{id}',[UserController::class,'profile'])->name('profile'); |
There was a problem hiding this comment.
As the profile should be only for the 'logged in' user, no need to pass the user id here.
| { | ||
| $users = User::paginate(5); | ||
| return view('user.list', compact('users')); | ||
| } |
There was a problem hiding this comment.
Add an empty line after the method.
|
|
||
| public function profileUpdate(ProfileRequest $request) | ||
| { | ||
| $request->validated(); |
There was a problem hiding this comment.
The indentation is wrong.
| } | ||
| public function index() | ||
| { | ||
| $users = User::paginate(5); |
There was a problem hiding this comment.
Don't hardcode the paginate value here. Set it as a constant in a global 'Constant' file or in the Model.
| use HasFactory, Notifiable,SoftDeletes; | ||
| const User ="User"; | ||
| const Role="Role"; | ||
| const Author="Author"; |
There was a problem hiding this comment.
The constant should be ROLE_AUTHOR.
| })->middleware(['auth'])->name('dashboard'); | ||
|
|
||
| Route::get('profile/{user}',[UserController::class,'profile'])->name('profile'); | ||
| Route::get('user/list',[UserController::class,'index'])->name('user-list'); |
There was a problem hiding this comment.
The route should be users.
|
|
||
| Route::get('profile/{user}',[UserController::class,'profile'])->name('profile'); | ||
| Route::get('user/list',[UserController::class,'index'])->name('user-list'); | ||
| Route::delete('user/delete/{user}',[UserController::class,'destroy'])->name('user-delete'); |
There was a problem hiding this comment.
The route should be users/{user} with the DELETE method.
| Route::get('user/list',[UserController::class,'index'])->name('user-list'); | ||
| Route::delete('user/delete/{user}',[UserController::class,'destroy'])->name('user-delete'); | ||
| Route::put('profile/update',[UserController::class,'profileUpdate'])->name('profile-update'); | ||
| Route::put('user/ban/{user}',[UserController::class,'Ban'])->name('ban-user'); |
There was a problem hiding this comment.
The route should be users/{user}/ban.
| $profile->update(); | ||
| return redirect()->back()->with('success','Profile updated'); | ||
| } | ||
| public function Ban(User $user) |
There was a problem hiding this comment.
The method name shouldn't have Uppercase Letter at the beginning.
| use Notifiable; | ||
| use SoftDeletes; | ||
|
|
||
| public const USER = "User"; |
There was a problem hiding this comment.
Rename this to ROLE_USER.
|
|
||
| public const USER = "User"; | ||
| public const ROLE_AUTHOR = "Author"; | ||
| public const BANNED = 1; |
There was a problem hiding this comment.
Rename this to STATUS_BANNED.
| } | ||
| $profile->update(); | ||
| return redirect()->back()->with('success','Profile updated'); | ||
| } |
| public function profile(User $user) | ||
| { | ||
| return view('profile', compact('user')); | ||
| } |
There was a problem hiding this comment.
Add an empty line after the method.
| } | ||
| public function profileUpdate(ProfileRequest $request) | ||
| { | ||
| $request->validated(); |
There was a problem hiding this comment.
This method call is redundant.
| @@ -72,4 +73,9 @@ public function changedReturnStatus() | |||
| { | |||
| return $this->hasMany(ReturnRequest::class,'status_changed_by'); | |||
| } | |||
| use SoftDeletes; | ||
|
|
||
| public const USER = "User"; | ||
| public const ROLE_AUTHOR = "Author"; |
There was a problem hiding this comment.
Shouldn't it be 'Librarian'? We don't have a 'Author' type user.
| 'name' => $this->faker->name, | ||
| 'email' => $this->faker->unique()->safeEmail, | ||
| 'role'=>User::User, | ||
| 'phone'=>$this->faker->phoneNumber, |
| @php($i=1) | ||
| @foreach($users as $user) | ||
| <tr> | ||
| <th>{{$i++}}</th> |
There was a problem hiding this comment.
Use $loop->index instead of managing your own loop variable.
me-shaon
left a comment
There was a problem hiding this comment.
Code Styling issues are not fixed yet.
|
add an empty line after the method or the unused method are not removed? |
Both. |
No description provided.