Changeset 0df7a93 for app


Ignore:
Timestamp:
10/24/21 20:55:11 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
develop, master
Children:
7043def
Parents:
e0d3f94
Message:

bug fixes

Location:
app
Files:
3 edited

Legend:

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

    re0d3f94 r0df7a93  
    88use App\Http\Requests\Dashboard\UpdateUserRequest;
    99use App\Models\Avatar;
     10use App\Models\Department;
     11use App\Models\Folder;
    1012use Carbon\Carbon;
    1113use Illuminate\Support\Facades\File;
     
    2628            "users" => User::all(),
    2729            "roles" => Role::all(),
     30            "adminAndReferents" => User::where("role_id", 1)->orWhere("role_id", 2)->get()
    2831        ]);
    2932    }
     
    138141        $user = User::find($id);
    139142
    140         $user->userProfile->delete();
    141         $user->delete();
     143        if(Folder::where('user_id', $user->id)->count() == 0) {
     144            if (Storage::disk("uploads")->exists("users" . DIRECTORY_SEPARATOR . $user->avatar)) {
     145                Storage::disk("uploads")->delete("users" . DIRECTORY_SEPARATOR . $user->avatar);
     146            }
    142147
    143         Alert::flash($user->name . " deleted successfully");
     148            $user->delete();
    144149
    145         return redirect()->route("dashboard.users.index");
     150            Alert::flash($user->name . " deleted successfully");
     151
     152            return redirect()->route("dashboard.users.index");
     153        }
     154        else {
     155            Alert::flash($user->name . "has associated folders");
     156
     157            return redirect()->back();
     158        }
    146159    }
    147160
  • app/Models/Department.php

    re0d3f94 r0df7a93  
    2828        return $this->hasMany(Folder::class);
    2929    }
     30
     31//    public function getDeptId(){
     32//        return Department::where('id', $this->id)->get();
     33//    }
    3034}
  • app/Models/User.php

    re0d3f94 r0df7a93  
    134134        return User::where('id', $this->created_by)->pluck('username')->first();
    135135    }
     136
     137    public function folder() {
     138        return $this->hasMany(Folder::class);
     139    }
    136140}
Note: See TracChangeset for help on using the changeset viewer.