- Timestamp:
- 10/24/21 20:55:11 (3 years ago)
- Branches:
- develop, master
- Children:
- 7043def
- Parents:
- e0d3f94
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/UsersController.php
re0d3f94 r0df7a93 8 8 use App\Http\Requests\Dashboard\UpdateUserRequest; 9 9 use App\Models\Avatar; 10 use App\Models\Department; 11 use App\Models\Folder; 10 12 use Carbon\Carbon; 11 13 use Illuminate\Support\Facades\File; … … 26 28 "users" => User::all(), 27 29 "roles" => Role::all(), 30 "adminAndReferents" => User::where("role_id", 1)->orWhere("role_id", 2)->get() 28 31 ]); 29 32 } … … 138 141 $user = User::find($id); 139 142 140 $user->userProfile->delete(); 141 $user->delete(); 143 if(Folder::where('user_id', $user->id)->count() == 0) { 144 if (Storage::disk("uploads")->exists("users" . DIRECTORY_SEPARATOR . $user->avatar)) { 145 Storage::disk("uploads")->delete("users" . DIRECTORY_SEPARATOR . $user->avatar); 146 } 142 147 143 Alert::flash($user->name . " deleted successfully");148 $user->delete(); 144 149 145 return redirect()->route("dashboard.users.index"); 150 Alert::flash($user->name . " deleted successfully"); 151 152 return redirect()->route("dashboard.users.index"); 153 } 154 else { 155 Alert::flash($user->name . "has associated folders"); 156 157 return redirect()->back(); 158 } 146 159 } 147 160
Note:
See TracChangeset
for help on using the changeset viewer.