Basic

Permission

Introduction

Permissions allow users to access certain features of a course or project site, depending on their roles, and on the decisions made by the site owner and the system administrator. The ability to do actions on your site (including viewing content, editing content, and changing configuration) is governed by permissions. Each permission has a name (such as View published content) and covers one action or a small subset of actions.


Default Permissions

These permissions are created through seeds while setup a project.

Field NameSectionDescription
Has Access of DashboardDashboardThis will allow user to see the link of dashboard.
Has Access of Setting SectionSettingThis will allow user to see the link of setting section.
Can Login In BackendBackendThis will allow user to login in the backend.
Has Access Of Users SectionUserThis will allow user to see the link of user section.
Can Create UsersUserThis will allow user to add anything in the user section.
Can Read UsersUserThis will allow user to view anything in the user section.
Can Update UsersUserThis will allow user to edit anything in the user section.
Can Delete UsersUserThis will allow user to delete anything in the user section.
Can Manage UsersUserThis will allow user to manage anything in the user section.
Can See Users Contact DetailsUserThis will allow user to view contact (email, mobile) detail in the user section.
Has Access Of Registrations SectionRegistrationThis will allow user see the link of registration section.
Can Create RegistrationsRegistrationThis will allow user to add anything in the registration section.
Can Create Users From RegistrationsRegistrationThis will allow user to add users in the registration section.
Can Read RegistrationsRegistrationThis will allow user to view anything in the registration section.
Can Update RegistrationsRegistrationThis will allow user to edit anything in the registration section.
Can Delete RegistrationsRegistrationThis will allow user to delete anything in the registration section.
Can Manage RegistrationsRegistrationThis will allow user to manage anything in the registration section.
Can See Registrations Contact DetailsRegistrationThis will allow user to view contact detail in the registration section.
Has Access Of Roles SectionRoleThis will allow user see the link of role section.
Can Create RolesRoleThis will allow user to add anything in the role section.
Can Read RolesRoleThis will allow user to view anything in the role section.
Can Update RolesRoleThis will allow user to edit anything in the role section.
Can Delete RolesRoleThis will allow user to delete anything in the role section.
Can Manage RolesRoleThis will allow user to manage anything in the role section.
Has Access Of Permissions SectionPermissionThis will allow user see the link of permission section.
Can Read PermissionsPermissionThis will allow user to view anything in the permission section.
Can Update PermissionsPermissionThis will allow user to edit anything in the permission section.
Can Manage PermissionsPermissionThis will allow user to manage anything in the permission section.
Has Access Of Media SectionMediaThis will allow user see the link of media section.
Can Create MediaMediaThis will allow user to add anything in the media section.
Can Read MediaMediaThis will allow user to view anything in the media section.
Can Update MediaMediaThis will allow user to edit anything in the media section.
Can Delete MediaMediaThis will allow user to delete anything in the media section.
Can Manage MediaMediaThis will allow user to manage anything in the media section.
Has Access Of Module SectionModuleThis will allow user see the link of module section.
Can Install ModuleModuleThis will allow user to install a module.
Can Delete ModuleModuleThis will allow user to delete a module.
Can Deactivate ModuleModuleThis will allow user to deactivate a module.
Can Activate ModuleModuleThis will allow user to activate a module.
Can Import Sample Data In ModuleModuleThis will allow user to import sample data in module.
Can Update ModuleModuleThis will allow user to update a module.
Can Read ModuleModuleThis will allow user to read a module.
Has Access Of Theme SectionThemeThis will allow user see the link of theme section.
Can Install ThemeThemeThis will allow user to install a theme.
Can Delete ThemeThemeThis will allow user to delete a theme.
Can Deactivate ThemeThemeThis will allow user to deactivate a theme.
Can Activate ThemeThemeThis will allow user to activate a theme.
Can Import Sample Data In ThemeThemeThis will allow user to import sample data in theme.
Can Update ThemeThemeThis will allow user to update a theme.
Can Read ThemeThemeThis will allow user to read a theme.
Has Access Of Advanced SectionAdvancedThis will allow user see the link of advanced section.

Create a Permission via VaahSeeder

User can create a permission through seeds. Create a json file of name permissions.json at .../VaahCms/Modules/{module_name}>/Database/Seeds/json/ this directory.

permissions.json

[

    {
        "name": "Has Access of Dashboard",
        "module": "<module_name>",
        "section": "<module_section_name>",
        "details": "This will allow user to see the link of dashboard."
    },
    {
        "name": "Has Access of Setting Section",
        "module": "vaahcms",
        "section": "Setting",
        "details": "This will allow user to see the link of setting section."
    },
    .........
]

To run this seed, you have to add some code in DatabaseTableSeeder.php at .../VaahCms/Modules/{module_name}>/Database/Seeds/ this directory.

DatabaseTableSeeder.php

<?php
namespace VaahCms\Modules\<module_name>\Database\Seeds;


use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use WebReinvent\VaahCms\Libraries\VaahSeeder;

class DatabaseTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        VaahSeeder::permissions(__DIR__.'/json/permissions.json');
    }

}

Assign permission to roles

You can add permissions to a role in Permissions section. By clicking on Role column, a page will open that contain list of Roles along with Yes/NO Button.

permission
How to check if a user has permission?

VaahCms provide a method to check the User's permission.

if(\Auth::user()->hasPermission('<permission_slug>'))
{
}

eg:

if(\Auth::user()->hasPermission('has-access-of-users-section'))
{
    //user has "has-access-of-users-section" permission
}


Copyright © 2024