Ignore:
Timestamp:
10/13/21 15:44:57 (3 years ago)
Author:
Berat Kjufliju <kufliju@…>
Branches:
develop, master
Children:
120759b
Parents:
194a359
Message:

added documents crud, added last_seen_to_user, edited views

File:
1 edited

Legend:

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

    r194a359 r24a616f  
    1111use App\Http\Controllers\Controller;
    1212use Illuminate\Support\Facades\Auth;
     13use Illuminate\Support\Facades\Storage;
    1314
    1415class DepartmentsController extends Controller
     
    1718    {
    1819        return view("dashboard.departments.index")->with([
    19             "departments" => Department::all()
     20            "departments" => Department::all(),
    2021        ]);
    2122    }
     
    3738        $department = Department::findOrFail($id);
    3839
     40        $oldDepartmentCode = $department->code;
     41
    3942        $department->name = $request->name;
    4043        $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        }
    4156
    4257        $department->save();
     
    5469        $department->code = $request->code;
    5570
     71        if(!Storage::disk('local')->has('Departments/' . $request->code)){
     72            Storage::disk('local')->makeDirectory('Departments/' . $request->code);
     73        }
     74
    5675        $department->user_id = auth()->id();
     76        $department->location = '/Departments/' . $request->code;
     77
     78        dd($department->location);
    5779
    5880        $department->save();
Note: See TracChangeset for help on using the changeset viewer.