PHP code example of delgont / armor

1. Go to this page and download the library: Download delgont/armor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

delgont / armor example snippets


Route::post('/posts/create', 'PostController@store')->middleware(['permission:can-create-post']);

@can('can-view-posts')
    html here
@endcan



/**
 * Permission Group
 */
namespace App;

use Delgont\Armor\PermissionRegistrar;

class ClientPermissionRegistrar extends PermissionRegistrar
{
    // Permissions related to client management
    const CAN_MANAGE_CLIENTS = 'can_manage_clients';
    const CAN_VIEW_CLIENTS = 'can_view_clients';
    const CAN_CREATE_CLIENTS = 'can_create_clients';
    const CAN_UPDATE_CLIENTS = 'can_update_clients';
    const CAN_DELETE_CLIENTS = 'can_delete_clients';

    // Permissions related to licenses
    const CAN_MANAGE_LICENSES = 'can_manage_licenses';
    const CAN_VIEW_LICENSES = 'can_view_licenses';
    const CAN_ASSIGN_LICENSES = 'can_assign_licenses';

    // Permissions related to client logs
    const CAN_VIEW_CLIENT_LOGS = 'can_view_client_logs';
    const CAN_DELETE_CLIENT_LOGS = 'can_delete_client_logs';

    /**
     * Provide descriptions for each permission.
     *
     * @return array
     */
    public function descriptions(): array
    {
        return [
            // Client management descriptions
            self::CAN_MANAGE_CLIENTS => 'Allows managing all aspects of client accounts.',
            self::CAN_VIEW_CLIENTS => 'Allows viewing client information.',
            self::CAN_CREATE_CLIENTS => 'Allows creating new client accounts.',
            self::CAN_UPDATE_CLIENTS => 'Allows updating client account details.',
            self::CAN_DELETE_CLIENTS => 'Allows deleting client accounts.',

            // License management descriptions
            self::CAN_MANAGE_LICENSES => 'Allows full management of licenses.',
            self::CAN_VIEW_LICENSES => 'Allows viewing license details.',
            self::CAN_ASSIGN_LICENSES => 'Allows assigning licenses to clients.',

            // Client log management descriptions
            self::CAN_VIEW_CLIENT_LOGS => 'Allows viewing logs related to client activities.',
            self::CAN_DELETE_CLIENT_LOGS => 'Allows deleting client logs from the system.',
        ];
    }
}