- Timestamp:
- 10/13/21 15:44:57 (3 years ago)
- Branches:
- develop, master
- Children:
- 120759b
- Parents:
- 194a359
- Location:
- app
- Files:
-
- 8 added
- 10 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 } -
app/Http/Kernel.php
r194a359 r24a616f 39 39 \App\Http\Middleware\VerifyCsrfToken::class, 40 40 \Illuminate\Routing\Middleware\SubstituteBindings::class, 41 \App\Http\Middleware\LastSeenUserActivity::class, 41 42 ], 42 43 -
app/Http/Requests/Dashboard/NewUserRequest.php
r194a359 r24a616f 30 30 "email" => "required|string|email|max:255|unique:users,email", 31 31 "username" => "required|min:8|unique:users,username", 32 "userRole" => "required|exists:roles,id" 32 "userRole" => "required|exists:roles,id", 33 "avatar" => "mimes:jpeg,png,gif|max:5000", 33 34 ]; 34 35 } -
app/Http/Requests/Dashboard/UpdateUserRequest.php
r194a359 r24a616f 30 30 "email" => "required|string|email|max:255|unique:users,email,$this->id,id", 31 31 "username" => "required|min:8|unique:users,username,$this->id,id", 32 "userRole" => "required|exists:roles,id" 32 "userRole" => "required|exists:roles,id", 33 "avatar" => "mimes:jpeg,png,gif|max:5000", 33 34 ]; 34 35 } -
app/Models/Department.php
r194a359 r24a616f 3 3 namespace App\Models; 4 4 5 use Illuminate\Database\Eloquent\Factories\HasFactory; 5 6 use Illuminate\Database\Eloquent\Model; 6 7 use Illuminate\Notifications\Notifiable; … … 9 10 { 10 11 use Notifiable; 12 use HasFactory; 11 13 12 14 protected $table = "departments"; 13 15 14 protected $fillable = ["name", "code", " user_id"];16 protected $fillable = ["name", "code", "location", "user_id"]; 15 17 16 18 protected $casts = [ … … 22 24 return User::where('id', $this->user_id)->pluck('username')->first(); 23 25 } 26 27 public function document(){ 28 return $this->hasMany(Document::class); 29 } 24 30 } -
app/Models/User.php
r194a359 r24a616f 25 25 "email", 26 26 "mobile_number", 27 "avatar", 27 28 "role_id" 28 29 ]; … … 126 127 return Str::random($length); 127 128 } 128 129 129 } -
app/Providers/RouteServiceProvider.php
r194a359 r24a616f 18 18 * @var string 19 19 */ 20 public const HOME = '/ home';20 public const HOME = '/dashboard'; 21 21 22 22 /**
Note:
See TracChangeset
for help on using the changeset viewer.