- Timestamp:
- 10/18/21 23:00:23 (3 years ago)
- Branches:
- develop, master
- Children:
- ea7b12a
- Parents:
- e6c1f87
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DepartmentsController.php
re6c1f87 rb9c4a92 14 14 use Illuminate\Support\Facades\Auth; 15 15 use Illuminate\Support\Facades\Storage; 16 use function Illuminate\Events\queueable; 16 17 17 18 class DepartmentsController extends Controller … … 36 37 $department->code = $request->code; 37 38 38 $l en = Storage::disk('local')->path('');39 $location = 'Departments' . DIRECTORY_SEPARATOR . $request->code; 39 40 40 if(!Storage::disk('local')->has('Departments/' . $request->code)){ 41 Storage::disk('local')->makeDirectory('Departments/' . $request->code); 41 if(!Storage::disk('local')->has($location)){ 42 Storage::disk('local')->makeDirectory($location); 43 42 44 } 43 45 $department->location = Storage::disk('local')->path('') . $location; 44 46 $department->user_id = auth()->id(); 45 $department->location = Storage::disk('local')->path('') . 'Departments/' . $request->code;46 47 47 48 $department->save(); … … 63 64 $department = Department::findOrFail($id); 64 65 65 $old DepartmentCode =$department->code;66 $oldLocation = DIRECTORY_SEPARATOR . 'Departments' . DIRECTORY_SEPARATOR . $department->code; 66 67 67 68 $department->name = $request->name; 68 69 $department->code = $request->code; 69 70 70 $department->location = Storage::disk('local')->path('') . 'Departments/' . $request->code;71 72 $files = Storage::allFiles($oldDepartmentCode);73 74 71 if($department->isDirty('code')) 75 72 { 76 if(!Storage::disk('local')->has('Departments/' . $request->code)){ 77 Storage::disk('local')->move('Departments/' . $oldDepartmentCode, 'Departments/' . $department->code); 73 $location = 'Departments' . DIRECTORY_SEPARATOR . $request->code; 74 if(!Storage::disk('local')->has($location)){ 75 Storage::disk('local')->move($oldLocation, $location); 76 $department->location = Storage::disk('local')->path('') . $location; 78 77 } 79 78 }
Note:
See TracChangeset
for help on using the changeset viewer.