Changeset 190db9f


Ignore:
Timestamp:
11/01/21 11:18:15 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
master
Children:
d95fdd2
Parents:
1451c6f
Message:

edited user permissions

Files:
3 deleted
10 edited

Legend:

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

    r1451c6f r190db9f  
    1111use App\Models\User;
    1212use App\Notifications\NewDepartmentCreated;
     13use App\Notifications\NewFolderCreated;
    1314use Carbon\Carbon;
    1415use App\Http\Controllers\Controller;
  • app/Http/Controllers/Dashboard/FoldersController.php

    r1451c6f r190db9f  
    151151
    152152        $users = User::all();
    153         Notification::send($users, new NewFolderCreated("New folder created"));
    154153
    155154        $folder->location = $location;
     
    246245        }
    247246
    248         if (auth()->user()->hasPermission("delete_all_folders")) {
     247        if (auth()->user()->hasPermission("delete_data")) {
    249248
    250249            foreach ($files as $file) {
  • app/Http/Requests/Dashboard/FolderRequest.php

    r1451c6f r190db9f  
    1919        if ($this->isMethod("patch")) {
    2020            $folder = Folder::find($this->route("id"));
    21             return auth()->user()->hasPermission("edit_all_folders") || ($folder->user->id == auth()->user()->id);
     21            return auth()->user()->hasPermission("manage_all_folders") || ($folder->user->id == auth()->user()->id);
    2222        }
    2323
  • database/seeders/PermissionsTableSeeder.php

    r1451c6f r190db9f  
    2323            ["id" => "5", "name" => "view_all_departments"],        // Access all departments to view
    2424            ["id" => "6", "name" => "view_all_folders"],                // Access all folders to view
    25             ["id" => "7", "name" => "edit_all_folders"],                    // Edit all folders
    26             ["id" => "8", "name" => "edit_folder"],                     // Edit your folder/s
    27             ["id" => "9", "name" => "delete_all_folders"],              // Delete all folder/s
    28             ["id" => "10", "name" => "delete_folder"],              // Delete your folder/s
    29             ["id" => "11", "name" => "view_all_files"],                 // View all files
    30             ["id" => "12", "name" => "manage_all_files"],               // Manage all files
    31             ["id" => "13", "name" => "manage_file_types"],              // Access file types
    32             ["id" => "14", "name" => "edit_user_data"],                 // Access file types
    33             ["id" => "15", "name" => "export_data"],                // Export data
    34             ["id" => "16", "name" => "download_data"],              // Download data
     25            ["id" => "7", "name" => "view_all_files"],              // View all files
     26            ["id" => "8", "name" => "manage_all_files"],                // Manage all files
     27            ["id" => "9", "name" => "manage_file_types"],               // Access file types
     28            ["id" => "10", "name" => "export_data"],                // Export data
     29            ["id" => "11", "name" => "download_data"],              // Download data
     30            ["id" => "12", "name" => "delete_data"],                // Delete data
    3531        ]);
    3632    }
  • database/seeders/RolesPermissionsTableSeeder.php

    r1451c6f r190db9f  
    2828            ["role_id" => 1, "permission_id" => 11],
    2929            ["role_id" => 1, "permission_id" => 12],
    30             ["role_id" => 1, "permission_id" => 13],
    31             ["role_id" => 1, "permission_id" => 14],
    32             ["role_id" => 1, "permission_id" => 15],
    33             ["role_id" => 1, "permission_id" => 16],
    3430
    3531            // Referent
    3632            ["role_id" => 2, "permission_id" => 1],
     33            ["role_id" => 2, "permission_id" => 3],
    3734            ["role_id" => 2, "permission_id" => 4],
    3835            ["role_id" => 2, "permission_id" => 5],
     
    4037            ["role_id" => 2, "permission_id" => 7],
    4138            ["role_id" => 2, "permission_id" => 8],
    42             ["role_id" => 2, "permission_id" => 9],
    43             ["role_id" => 2, "permission_id" => 10],
    4439            ["role_id" => 2, "permission_id" => 11],
    45             ["role_id" => 2, "permission_id" => 12],
    46             ["role_id" => 2, "permission_id" => 14],
    47             ["role_id" => 2, "permission_id" => 15],
    48             ["role_id" => 2, "permission_id" => 16],
    4940
    5041            // Viewer
    5142            ["role_id" => 3, "permission_id" => 5],
    5243            ["role_id" => 3, "permission_id" => 6],
    53             ["role_id" => 3, "permission_id" => 11]
     44            ["role_id" => 3, "permission_id" => 7],
     45            ["role_id" => 3, "permission_id" => 11],
    5446        ]);
    5547    }
  • resources/views/dashboard/departments/index.blade.php

    r1451c6f r190db9f  
    8989                                        </a>
    9090                                        @endif
     91                                        @if(auth()->user()->hasPermission('delete_data'))
    9192                                        <a href="javascript:void(0)" class="text-danger ml-2" data-toggle="modal" data-target="#deleteModal_{{$department->id}}" title="Delete">
    9293                                            <i class="ti-trash"></i>
    9394                                        </a>
     95                                            @endif
    9496                                    </td>
    9597                                    @else
  • resources/views/dashboard/files/index.blade.php

    r1451c6f r190db9f  
    109109                                            <i class="ti-download"></i>
    110110                                        </a>
     111                                        @if(auth()->user()->hasPermission('delete_data'))
    111112                                        <a href="javascript:void(0)" class="text-danger ml-2" data-toggle="modal" data-target="#deleteModal_{{$file->id}}" title="Delete">
    112113                                            <i class="ti-trash"></i>
    113114                                        </a>
     115                                            @endif
    114116                                    </td>
    115117                                    @else
  • resources/views/dashboard/folders/files.blade.php

    r1451c6f r190db9f  
    107107                                        </a>
    108108                                            @endif
    109                                             @if(auth()->user()->hasPermission('manage_all_files'))
     109                                            @if(auth()->user()->hasPermission('delete_data'))
    110110                                        <a href="javascript:void(0)" class="dropdown-item" data-toggle="modal" data-target="#deleteModal_{{$file->id}}">
    111111                                            Delete
  • resources/views/dashboard/folders/index.blade.php

    r1451c6f r190db9f  
    152152                                            <a href="{{ route("dashboard.folders.downloadFolder", ['id' => $folder->id]) }}" class="dropdown-item">Download</a>
    153153                                            @endif
    154                                             @if(auth()->user()->hasPermission('manage_all_folders'))
     154                                            @if(auth()->user()->hasPermission('delete_data'))
    155155                                            <a href="javascript:void(0)" class="dropdown-item" data-toggle="modal" data-target="#deleteModal_{{$folder->id}}">Delete</a>
    156156                                            @endif
  • routes/web.php

    r1451c6f r190db9f  
    8888        Route::get("/departments/{id}/edit", "Dashboard\DepartmentsController@editShow")->name("dashboard.departments.editShow");
    8989        Route::patch("/departments/{id}/edit", "Dashboard\DepartmentsController@edit")->name("dashboard.departments.edit");
    90         Route::delete("/departments/{id}/destroy", "Dashboard\DepartmentsController@destroy")->name("dashboard.departments.destroy");
    9190     });
    9291
     
    102101        Route::post("/folders/store", "Dashboard\FoldersController@store")->name("dashboard.folders.store");
    103102        Route::get("/folders/{id}/edit", "Dashboard\FoldersController@editShow")->name("dashboard.folders.editShow");
    104         Route::delete("/folders/{id}/destroy", "Dashboard\FoldersController@destroy")->name("dashboard.folders.destroy");
    105103        Route::post("/folders/{id}/upload", "Dashboard\FoldersController@uploadFiles")->name("dashboard.folders.uploadFiles");
    106 
    107104    });
    108105
     
    114111    //Files manage
    115112Route::group(['middleware' => 'permission:manage_all_files'], function () {
    116     Route::patch("files/{id}/rename-file", "Dashboard\FilesController@renameFile")->name("dashboard.files.renameFile");
    117113    Route::post("/files/store", "Dashboard\FilesController@store")->name("dashboard.files.store");
    118     Route::delete("files/{id}/delete-file", "Dashboard\FilesController@deleteFile")->name("dashboard.files.deleteFile");
    119114    });
    120115
     
    134129        Route::get('/departments/{id}/download-department', 'Dashboard\DepartmentsController@downloadDepartment')->name('dashboard.departments.downloadDepartment');
    135130    });
     131
     132    //Delete data
     133    Route::group(['middleware' => 'permission:delete_data'], function() {
     134        Route::delete("files/{id}/delete-file", "Dashboard\FilesController@deleteFile")->name("dashboard.files.deleteFile");
     135        Route::delete("/folders/{id}/destroy", "Dashboard\FoldersController@destroy")->name("dashboard.folders.destroy");
     136        Route::delete("/departments/{id}/destroy", "Dashboard\DepartmentsController@destroy")->name("dashboard.departments.destroy");
     137    });
    136138});
Note: See TracChangeset for help on using the changeset viewer.