- Timestamp:
- 10/24/21 20:55:11 (3 years ago)
- Branches:
- develop, master
- Children:
- 7043def
- Parents:
- e0d3f94
- Location:
- app
- Files:
-
- 3 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 -
app/Models/Department.php
re0d3f94 r0df7a93 28 28 return $this->hasMany(Folder::class); 29 29 } 30 31 // public function getDeptId(){ 32 // return Department::where('id', $this->id)->get(); 33 // } 30 34 } -
app/Models/User.php
re0d3f94 r0df7a93 134 134 return User::where('id', $this->created_by)->pluck('username')->first(); 135 135 } 136 137 public function folder() { 138 return $this->hasMany(Folder::class); 139 } 136 140 }
Note:
See TracChangeset
for help on using the changeset viewer.