Modules/Security/Database/Seeds/RolesSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        $roleRepo = app(RoleRepository::class);
        Role::truncate();
        RoleCategory::truncate();
        $categories = [
            [
                'name' => 'adminCPanel'
            ],
            [
                'name' => 'userFrontend'
            ]
        ];
        foreach ($categories as $category){
            $roleRepo->saveRoleCategory($category);
        }
        $admin_cpanel_role_category = $roleRepo->getCategoryByName('adminCPanel');
        $roles = [
            [
                'name' => 'super_admin',
                'description' => 'Super Admin',
                'category_id' => $admin_cpanel_role_category->id
            ],
            [
                'name' => 'admin',
                'description' => 'Admin',
                'category_id' => $admin_cpanel_role_category->id
            ]
        ];
        foreach ($roles as $role){
            $roleRepo->saveRole($role);
        }
    }
public function run ( ) { $ roleRepo = app ( RoleRepository :: class ) ; Role :: truncate ( ) ; RoleCategory :: truncate ( ) ; $ categories = [ [ 'name' => 'adminCPanel' ] , [ 'name' => 'userFrontend' ] ] ; foreach ( $ categories as $ category ) { $ roleRepo -> saveRoleCategory ( $ category ) ; } $ admin_cpanel_role_category = $ roleRepo -> getCategoryByName ( 'adminCPanel' ) ; $ roles = [ [ 'name' => 'super_admin' , 'description' => 'Super Admin' , 'category_id' => $ admin_cpanel_role_category -> id ] , [ 'name' => 'admin' , 'description' => 'Admin' , 'category_id' => $ admin_cpanel_role_category -> id ] ] ; foreach ( $ roles as $ role ) { $ roleRepo -> saveRole ( $ role ) ; } }
Run the database seeds.
Run the database seeds .
/**
         * @var RoleRepository $roleRepo
         */ // todo:: create role categories // todo:: create roles