diff --git a/app/Http/Controllers/Backend/Instructors/InstructorController.php b/app/Http/Controllers/Backend/Instructors/InstructorController.php index b6003e6..61af7ea 100644 --- a/app/Http/Controllers/Backend/Instructors/InstructorController.php +++ b/app/Http/Controllers/Backend/Instructors/InstructorController.php @@ -56,8 +56,9 @@ public function store(AddNewRequest $request) $instructor->language = 'en'; $instructor->access_block = $request->access_block; if ($request->hasFile('image')) { - $imageName = rand(111, 999) . time() . '.' . $request->image->extension(); - $request->image->move(public_path('uploads/instructors'), $imageName); + $roleName = Role::find($request->role_id)?->name; + $imageName = $roleName.'-'.$request->name_en.'.'. $request->image->extension(); + $request->image->move(public_path('uploads/users'), $imageName); $instructor->image = $imageName; } if ($instructor->save()) { @@ -69,6 +70,9 @@ public function store(AddNewRequest $request) $user->role_id = $request->roleId; $user->status = $request->status; $user->password = Hash::make($request->password); + if (isset($imageName)) { + $user->image = $imageName; // Save the image name in the users table + } if ($user->save()) { DB::commit(); $this->notice::success('Successfully saved'); @@ -129,8 +133,9 @@ public function update(UpdateRequest $request, $id) $instructor->access_block = $request->access_block; if ($request->hasFile('image')) { - $imageName = rand(111, 999) . time() . '.' . $request->image->extension(); - $request->image->move(public_path('uploads/instructors'), $imageName); + $roleName = Role::find($request->role_id)?->name; + $imageName = $roleName . '-' . $request->name_en . '.' . $request->image->extension(); + $request->image->move(public_path('uploads/users'), $imageName); $instructor->image = $imageName; } if ($instructor->save()) { @@ -142,6 +147,9 @@ public function update(UpdateRequest $request, $id) $user->role_id = $request->roleId; $user->status = $request->status; $user->password = Hash::make($request->password); + if (isset($imageName)) { + $user->image = $imageName; // Save the image name in the users table + } if ($user->save()) { DB::commit(); $this->notice::success('Successfully saved'); diff --git a/public/uploads/instructors/1971708533737.png b/public/uploads/instructors/1971708533737.png new file mode 100644 index 0000000..9e90a6c Binary files /dev/null and b/public/uploads/instructors/1971708533737.png differ diff --git a/public/uploads/instructors/3321708533352.png b/public/uploads/instructors/3321708533352.png new file mode 100644 index 0000000..a290866 Binary files /dev/null and b/public/uploads/instructors/3321708533352.png differ diff --git a/public/uploads/instructors/3931708534567.png b/public/uploads/instructors/3931708534567.png new file mode 100644 index 0000000..a290866 Binary files /dev/null and b/public/uploads/instructors/3931708534567.png differ diff --git a/public/uploads/instructors/7681708533867.jpg b/public/uploads/instructors/7681708533867.jpg new file mode 100644 index 0000000..ac5f394 Binary files /dev/null and b/public/uploads/instructors/7681708533867.jpg differ diff --git a/public/uploads/instructors/9121708534063.png b/public/uploads/instructors/9121708534063.png new file mode 100644 index 0000000..a290866 Binary files /dev/null and b/public/uploads/instructors/9121708534063.png differ diff --git a/resources/views/backend/instructor/index.blade.php b/resources/views/backend/instructor/index.blade.php index 3c3dbfe..d34b16e 100644 --- a/resources/views/backend/instructor/index.blade.php +++ b/resources/views/backend/instructor/index.blade.php @@ -63,7 +63,7 @@ class="nav-link btn-primary mr-1 show active">List View