Ignore:
Timestamp:
10/18/21 23:00:23 (3 years ago)
Author:
Berat Kjufliju <kufliju@…>
Branches:
develop, master
Children:
ea7b12a
Parents:
e6c1f87
Message:

edited file upload, seeding and departments controller

File:
1 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/Dashboard/DepartmentsController.php

    re6c1f87 rb9c4a92  
    1414use Illuminate\Support\Facades\Auth;
    1515use Illuminate\Support\Facades\Storage;
     16use function Illuminate\Events\queueable;
    1617
    1718class DepartmentsController extends Controller
     
    3637        $department->code = $request->code;
    3738
    38         $len = Storage::disk('local')->path('');
     39        $location = 'Departments' . DIRECTORY_SEPARATOR . $request->code;
    3940
    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
    4244        }
    43 
     45        $department->location = Storage::disk('local')->path('') . $location;
    4446        $department->user_id = auth()->id();
    45         $department->location =  Storage::disk('local')->path('') . 'Departments/' . $request->code;
    4647
    4748        $department->save();
     
    6364        $department = Department::findOrFail($id);
    6465
    65         $oldDepartmentCode = $department->code;
     66        $oldLocation = DIRECTORY_SEPARATOR . 'Departments' . DIRECTORY_SEPARATOR . $department->code;
    6667
    6768        $department->name = $request->name;
    6869        $department->code = $request->code;
    6970
    70         $department->location =  Storage::disk('local')->path('') . 'Departments/' . $request->code;
    71 
    72         $files = Storage::allFiles($oldDepartmentCode);
    73 
    7471        if($department->isDirty('code'))
    7572        {
    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;
    7877            }
    7978        }
Note: See TracChangeset for help on using the changeset viewer.