Changeset 24a616f for app/Http/Controllers/Dashboard
- Timestamp:
- 10/13/21 15:44:57 (3 years ago)
- Branches:
- develop, master
- Children:
- 120759b
- Parents:
- 194a359
- Location:
- app/Http/Controllers/Dashboard
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DepartmentsController.php
r194a359 r24a616f 11 11 use App\Http\Controllers\Controller; 12 12 use Illuminate\Support\Facades\Auth; 13 use Illuminate\Support\Facades\Storage; 13 14 14 15 class DepartmentsController extends Controller … … 17 18 { 18 19 return view("dashboard.departments.index")->with([ 19 "departments" => Department::all() 20 "departments" => Department::all(), 20 21 ]); 21 22 } … … 37 38 $department = Department::findOrFail($id); 38 39 40 $oldDepartmentCode = $department->code; 41 39 42 $department->name = $request->name; 40 43 $department->code = $request->code; 44 45 $path = '/Departments/' . $request->code; 46 $department->location = $path; 47 48 $files = Storage::allFiles($oldDepartmentCode); 49 50 if($department->isDirty('code')) 51 { 52 if(!Storage::disk('local')->has('Departments/' . $request->code)){ 53 Storage::disk('local')->move('Departments/' . $oldDepartmentCode, 'Departments/' . $department->code); 54 } 55 } 41 56 42 57 $department->save(); … … 54 69 $department->code = $request->code; 55 70 71 if(!Storage::disk('local')->has('Departments/' . $request->code)){ 72 Storage::disk('local')->makeDirectory('Departments/' . $request->code); 73 } 74 56 75 $department->user_id = auth()->id(); 76 $department->location = '/Departments/' . $request->code; 77 78 dd($department->location); 57 79 58 80 $department->save(); -
app/Http/Controllers/Dashboard/IndexController.php
r194a359 r24a616f 15 15 ); 16 16 17 Alert::flash("test");18 19 17 return view("dashboard.index")->with([ 20 18 "counters" => $counters, -
app/Http/Controllers/Dashboard/SettingsController.php
r194a359 r24a616f 9 9 use App\Http\Requests\Dashboard\PhotosSettingsRequest; 10 10 use App\Http\Requests\Dashboard\SocialLinksSettingsRequest; 11 use App\Http\Requests\Dashboard\UpdateUserData; 12 use App\Http\Requests\Dashboard\UpdateUserRequest; 11 13 use App\Http\Requests\Dashboard\UsernameSettingsRequest; 12 14 use App\Http\Requests\Dashboard\UserProfileSettingsRequest; … … 78 80 } 79 81 80 81 82 82 } -
app/Http/Controllers/Dashboard/UsersController.php
r194a359 r24a616f 5 5 use App\Helpers\Alert; 6 6 use App\Http\Requests\Dashboard\NewUserRequest; 7 use App\Http\Requests\Dashboard\UpdateUserData; 7 8 use App\Http\Requests\Dashboard\UpdateUserRequest; 9 use App\Models\Avatar; 10 use Illuminate\Support\Facades\File; 8 11 use App\Models\Role; 9 12 use App\Models\User; … … 12 15 use App\Notifications\WelcomeUser; 13 16 use App\Http\Controllers\Controller; 17 use Illuminate\Support\Facades\Storage; 14 18 15 19 class UsersController extends Controller 16 20 { 21 17 22 public function index() 18 23 { … … 44 49 $user->role_id = $request->userRole; 45 50 51 if ($request->hasFile("avatar")) { 52 $image = $request->file("avatar"); 53 $avatarName = $user->id . '_avatar' . time() . '.' . request()->avatar->getClientOriginalExtension(); 54 55 if (!empty($user->avatar)) { 56 Storage::disk('uploads')->delete("/users/" . $user->avatar); 57 } 58 59 Storage::disk('uploads')->put("/users/" . $avatarName, File::get($image)); 60 61 $user->avatar = $avatarName; 62 } 46 63 $user->save(); 47 64 … … 70 87 $user->mobile_number = $request->mobile_number; 71 88 $user->role_id = $request->userRole; 89 90 if ($request->hasFile("avatar")) { 91 $image = $request->file("avatar"); 92 $avatarName = $user->id . '_avatar' . time() . '.' . request()->avatar->getClientOriginalExtension(); 93 94 if (!empty($user->avatar)) { 95 Storage::disk('uploads')->delete("/users/" . $user->avatar); 96 } 97 98 Storage::disk('uploads')->put("/users/" . $avatarName, File::get($image)); 99 100 $user->avatar = $avatarName; 101 } 102 72 103 if($user->isDirty('email')) { 73 104 $user->notify(new VerifyNewEmail($user)); … … 78 109 79 110 return redirect()->route("dashboard.users.index"); 80 }81 82 public function editUserData(UpdateUserRequest $request, $id)83 {84 $user = User::findOrFail($id);85 $user->name = $request->name;86 $user->surname = $request->surname;87 $user->mobile_number = $request->mobile_number;88 89 $user->save();90 91 Alert::flash("User data updated successfully");92 93 return redirect()->route("dashboard.settings.index");94 111 } 95 112 … … 129 146 return $roles; 130 147 } 148 149 public function editUserData(UpdateUserData $request, $id) 150 { 151 $user = User::findOrFail($id); 152 $user->name = $request->name; 153 $user->surname = $request->surname; 154 $user->mobile_number = $request->mobile_number; 155 156 if ($request->hasFile("avatar")) { 157 $image = $request->file("avatar"); 158 $avatarName = $user->id . '_avatar' . time() . '.' . request()->avatar->getClientOriginalExtension(); 159 160 if (!empty($user->avatar)) { 161 Storage::disk('uploads')->delete("/users/" . $user->avatar); 162 } 163 164 Storage::disk('uploads')->put("/users/" . $avatarName, File::get($image)); 165 166 $user->avatar = $avatarName; 167 } 168 169 $user->save(); 170 171 Alert::flash("User data updated successfully"); 172 173 return redirect()->route("dashboard.settings.index"); 174 } 131 175 }
Note:
See TracChangeset
for help on using the changeset viewer.