- Timestamp:
- 10/13/21 15:44:57 (3 years ago)
- Branches:
- develop, master
- Children:
- 120759b
- Parents:
- 194a359
- File:
-
- 1 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();
Note:
See TracChangeset
for help on using the changeset viewer.