Download the PHP package obrainwave/access-tree without Composer
On this page you can find all versions of the php package obrainwave/access-tree. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download obrainwave/access-tree
More information about obrainwave/access-tree
Files in obrainwave/access-tree
Package access-tree
Short Description This package allows you to manage user permissions and roles in a database for Laravel project
License MIT
Homepage https://github.com/obrainwave/access-tree
Informations about the package access-tree
Laravel Access Tree
π AccessTree 2.2.0 - Major Release
Version 1.x is deprecated. Please follow the Upgrade Guide before updating.
What's New in 2.2?
- π¨ Complete Admin Interface: Modern, responsive admin panel with dark mode
- ποΈ Universal Table Management: Automatically manage ALL database tables with full CRUD
- π Dynamic Dashboard: Real-time statistics and recent activity feed
- π Dark/Light Mode: Beautiful UI theme switcher
- π System Logs Viewer: View and manage application logs
- βοΈ System Settings: Monitor system health and performance
- π Custom Pagination: Modern, styled pagination with dark mode
- π± Fully Responsive: Works perfectly on all devices
- π₯ Sticky Header: Always-visible header with breadcrumbs
- β¨ Smooth Animations: Professional transitions and hover effects
And much more! See the Features section below.
A comprehensive Laravel package for managing user permissions and roles with database-driven access control.
This package is a lightweight, database-driven RBAC (roles & permissions) package for Laravel with convenient helpers, facades, caching, seeding and middleware.
Quick Start (2 minutes)
Add trait to your User model:
Access the Admin Panel: Visit /admin/accesstree/login after creating a user.
You're done β roles, permissions and a seeded admin are ready (if seeding enabled).
Features
Core Features
- Role-Based Access Control (RBAC): Create and manage roles with specific permissions
- User Role Assignment: Assign multiple roles to users with easy synchronization
- Permission Checking: Helper functions for checking permissions and roles
- Root User Bypass: Special superuser capability that bypasses all permission checks
- Caching System: Built-in caching for optimal performance
- Blade Directives: Easy-to-use directives for view-level authorization
- Customisable Seeder: Seeder with default permissions/roles (publishable for customisation)
- Flexible API: Service classes, Facades, and global helper functions
Admin Interface (New in 2.0+)
- π₯οΈ Built-in Admin Dashboard: Complete admin interface with modern, responsive design
- π Dark/Light Mode Toggle: UI theme switcher with localStorage persistence
- π Dynamic Dashboard: Real-time statistics and recent activity feed
- π Universal Table Management: Automatically manage ALL database tables with full CRUD
- π Configurable Table Management: Control which tables appear in the sidebar and dashboard
- π¨ Modern UI/UX: Gradient backgrounds, animations, glassmorphism effects
- π± Fully Responsive: Mobile-friendly design that works on all devices
- π Secure Authentication: Built-in login system for admin access
- π System Logs Viewer: View and manage application logs from the admin panel
- βοΈ System Settings: Monitor system information, storage, and performance
- π Custom Pagination: Beautiful, modern pagination with dark mode support
- π₯ Sticky Header: Fixed header with breadcrumbs and quick actions
- π― Dynamic Sidebar: Auto-discover and list all database tables
- β¨ Smooth Animations: Professional transitions and hover effects
Requirements & Compatibility
- PHP: 8.1+
- Laravel: 8.x, 9.x, 10.x, 11.x, 12.x
- The package is continuously tested on the latest stable Laravel versions.
- Please open an issue
Installation
1. Require via Composer
Publish and Run Migrations
After running migration, a new column is_root_user will be added to the users table.
Installation Options
The package provides flexible installation options:
Configuration
Publish Config File
Config File Options
After publishing the config file (config/accesstree.php), you can customize the package behavior:
Publish Seeder (Optional)
Seeding Features
The package includes a powerful seeding system that can automatically set up your permissions and roles:
Default Permissions Created:
- User Management:
view user,add user,edit user,delete user - Role Management:
view role,add role,edit role,delete role - Permission Management:
view permission,add permission,edit permission,delete permission - Content Management: Common CRUD operations for your application
Default Roles Created:
- Super Admin: Has all permissions
- Admin: Has all permissions except permission control
- Editor: Can create, read, and update content
Seeding
After publishing the seeder, you can customize it at database/seeders/PermissionSeeder.php and run:
Automatic First User as Admin
If enabled in the config file:
The package will automatically assign the very first registered user the Admin role (if it exists).
- Ensures you always have at least one administrator.
- Works only on the first user (ID=1 typically).
- If you donβt want this behavior, simply set:
Add Trait to User Model
Basic Usage
Creating Permissions and Roles
Using service class or the service facade
Using Helper Functions
Managing User Roles
Checking Permissions and Roles
Blade Directives
Root User Feature
Admin Interface
Getting Started with Admin Interface
The AccessTree package includes a powerful built-in admin interface for managing permissions, roles, users, and all your database tables.
Installation
Access the Admin Panel
- Visit
/admin/accesstree/login - Login with your user credentials
- Access the full admin dashboard
Features
Dashboard
- Real-time Statistics: View total permissions, roles, and users
- Recent Activity: See the latest permissions, roles, and users created
- Managed Tables Overview: Cards showing managed database tables with record counts
- System Status: Monitor system health and performance
Permission Management
- Create, view, edit, and delete permissions
- Search and filter permissions
- Paginated list view
Role Management
- Create, view, edit, and delete roles
- Assign permissions to roles (multi-select with 3-column layout)
- Manage role-permission relationships
User Management
- View all users
- Assign roles to users
- Manage user-role relationships
Universal Table Management (New!)
Automatically manage ALL database tables with full CRUD operations:
Features:
- Auto-discovery: Automatically lists all your database tables in the sidebar
- Full CRUD: Create, Read, Update, Delete for any table
- Smart Field Detection: Automatically detects field types and renders appropriate inputs
- Search & Filter: Search across table records
- Pagination: Modern, responsive pagination
- Bulk Actions: Delete records in bulk
System Pages
- System Settings: View PHP version, Laravel version, environment info, database/cache drivers, storage usage, database size
- System Logs: View, refresh, download, and clear application logs in real-time
UI Features
- Dark/Light Mode: Toggle between themes with localStorage persistence
- Responsive Design: Works perfectly on desktop, tablet, and mobile
- Sticky Header: Always-visible header with breadcrumbs
- Modern Sidebar: Gradient background with smooth animations
- Custom Pagination: Beautiful pagination with dark mode support
- Dynamic Favicon: Auto-generated favicon based on app name
Configuring Universal Table Management
By default, the admin interface manages ALL database tables. You can configure this:
Dashboard Table Cards:
Customization
Custom Favicon
Custom Styling
Custom CSS Examples
Simple Branding (.env file):
Complex Styling (config file):
Custom JavaScript Examples
Simple Analytics (.env file):
Advanced Functionality (config file):
Environment Variables (.env)
Accessing Admin Programmatically
The admin routes are automatically registered. You can customize them by publishing and editing routes/accesstree-admin.php.
Default Route Prefix: /admin/accesstree
Middleware Usage
Protect your routes:
Middleware supports role:slug prefix to explicitly request role checks. It returns JSON 403 for XHR or redirects back/route with danger flash message.
Artisan Commands
Available Commands
Command Descriptions
Core Commands
accesstree:seed- Seed default permissions and rolesaccesstree:install- Complete package installationaccesstree:install --with-admin- Install with admin interfaceaccesstree:install --with-gates- Install with Laravel Gates integrationaccesstree:install --with-admin --with-gates- Install with both admin interface and gatesaccesstree:install --force- Force reinstall (overwrites existing files)accesstree:install-admin-interface- Install admin interface components
User Management
accesstree:create-admin-user- Create an admin user for the interfaceaccesstree:configure-user-model- Configure the User model for your applicationaccesstree:test-user-model- Test if the User model is properly configured
Table Management
accesstree:discover-tables- Discover all database tables in your applicationaccesstree:setup-universal-admin- Set up universal table management
Styling & UI
accesstree:configure-styling- Configure CSS framework and theme optionsaccesstree:publish-modern-css- Publish modern dashboard CSS
Testing & Debugging
accesstree:test-access-tree- Test core AccessTree functionalityaccesstree:test-views- Test if admin views are properly loadedaccesstree:test-dynamic-sidebar- Test dynamic sidebar functionalityaccesstree:test-table-routes- Test universal table routesaccesstree:test-route-access {table} {id}- Test access to specific table recordsaccesstree:test-universal-routes- Test universal table route generationaccesstree:test-actual-route {table} {id}- Test actual route executionaccesstree:test-route-with-auth {table} {id}- Test routes with authenticationaccesstree:check-routes- Check if all admin routes are properly registeredaccesstree:debug-admin-routes- Debug admin route issues
Maintenance
accesstree:cleanup-test-data- Clean up test data created during testingaccesstree:clear-cache- Clear all AccessTree-related caches
Warning:
Unlike php artisan migrate:fresh, this command does not wipe your entire database.
It will only truncate AccessTree-related tables defined in config/accesstree.php (by default):
permissionsrolesrole_has_permissionsuser_rolesThis ensures your application data remains safe while reseeding roles & permissions.
Advanced Usage
Using Service Directly
Data Retrieval
Available Methods
Service Class Methods
createAccess(array $data, string $model, array $permission_ids = [])updateAccess(array $data, string $model, array $permission_ids = [])deleteAccess(int $data_id, string $model)
HasRole Trait Methods
roles()- Relationship to user's rolesassignRole($role)- Assign single roleassignRoles($roles)- Assign multiple rolessyncRoles($roles)- Sync user roleshasRole($role)- Check if user has rolepermissions()- Get user's permissionshasPermission($permission)- Check if user has permission
Helper Functions
checkPermission(string $permission): boolcheckPermissions(array $permissions, bool $strict = false): boolcheckRole(string $role): boolcheckRoles(array $roles, bool $strict = false): boolisRootUser(int $user_id = null): boolcreateAccess(array $data, string $model, array $permission_ids = []): stringupdateAccess(array $data, string $model, array $permission_ids = []): stringfetchPermissions(array $options = [], int $status = 0): objectfetchRoles(array $options = [], int $status = 0): objectfetchUserRoles(int $user_id, bool $with_relation = true): object
Database Schema
The package creates these tables:
permissions- Stores permission recordsroles- Stores role recordsrole_has_permissions- Role-permission relationshipsuser_roles- User-role relationships
Caching & Performance
- Permission and role checks are cached per-user for
cache_refresh_time(config). - Use
config('accesstree.cache_refresh_time')to control minutes. - If you change permissions/role assignments programmatically, make sure to clear/refresh cache for affected users if necessary.
Testing
Quick example using Laravel feature testing:
Seeders can be run in tests to prepare default roles/permissions.
API Responses & AJAX (example)
When using the package with AJAX (e.g., to modify roles/permissions), the package returns JSON from service controllers (if you build them) and helper functions can be adapted to return structured responses (status/message). Keep errors user-friendly in production, and enable dev logging in local env.
Security
If you discover any security issues, please email the maintainers at ([email protected]) instead of using the issue tracker.
License
The MIT License (MIT). Please see LICENSE.md for more information.
Contributing
We welcome contributions! Please see CONTRIBUTING.md for coding standards, testing instructions, and local development setup.
Roadmap
β Completed (v2.2+)
- β Admin UI with modern design
- β Dark/Light mode toggle
- β Universal table management
- β System logs viewer
- β System settings page
- β Custom pagination
- β Responsive design
- β Dynamic sidebar
- β Dashboard with statistics and recent activity
- β Sticky header with breadcrumbs
- β Artisan command to clear package caches
π Planned Improvements
- Livewire / Inertia / Filament integration examples
- Per-tenant role scoping (multitenancy)
- Advanced filtering and sorting for universal tables
- Bulk operations for multiple tables
- Export/Import functionality for table data
- Custom field validation rules
- API endpoints for admin operations
- Audit logging for permission/role changes
If you want any roadmap item prioritized β open an issue or PR.
Acknowledgements
Inspired by common RBAC patterns (and packages like spatie/laravel-permission). Access Tree focuses on lightweight, configurable seeding and an intuitive helper API.
All versions of access-tree with dependencies
spatie/laravel-package-tools Version ^1.14.0
illuminate/contracts Version *