Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»DirectoryTree Authorization is a Native Role and Permission Management Package for Laravel

    DirectoryTree Authorization is a Native Role and Permission Management Package for Laravel

    April 26, 2024

    The DirectoryTree Authorization package by Steve Bauman is an easy, native role and permission management system for Laravel.

    If you need a super simple native feeling Laravel Authorization package, this one may tickle your fancyhttps://t.co/Xiu4Ty0IkR

    — Steve (@ste_bau) April 23, 2024 <script async src=”https://platform.twitter.com/widgets.js” charset=”utf-8″></script>

    It works with Laravel’s Gate and authorization methods out of the box, and offers the following lightweight API to manage roles and permissions:

    use DirectoryTreeAuthorizationPermission;
    use DirectoryTreeAuthorizationRole;

    $createUsers = Permission::create([
    ‘name’ => ‘users.create’,
    ‘label’ => ‘Create Users’,
    ]);

    $admin = Role::create([
    ‘name’ => ‘administrator’,
    ‘label’ => ‘Admin’,
    ]);

    // Grant the permission to a role
    $admin->permissions()->save($createUsers);

    // Assign the role to a user
    $user->roles()->save($admin);

    // `can()` method usage in PHP:
    Auth::user()->can(‘users.create’);

    // Using Laravel’s `Gate`:
    Gate::allows(‘users.create’);

    // Using Laravel’s `@can()` directive:
    @can(‘users.create’)
    <!– This user can create other users. –>
    @endcan

    The above code snippet doesn’t contain every method available—see the readme for usage details on managing roles and permissions with this package, which includes the following main features:

    Manage User roles and Permissions
    Create user-specific permissions
    Checking permissions and roles
    Caching permissions by default
    Use with Laravel’s native Gate and authorization methods.
    Permissions are registered in Laravel’s Gate by default
    Includes useful permission and role middleware

    To get started with this package, check out package on GitHub at directorytree/authorization.

    The post DirectoryTree Authorization is a Native Role and Permission Management Package for Laravel appeared first on Laravel News.

    Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleThe history of Frontend
    Next Article IICS Micro and Macro Services

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 17, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-4831 – TOTOLINK HTTP POST Request Handler Buffer Overflow Vulnerability

    May 17, 2025
    Leave A Reply Cancel Reply

    Hostinger

    Continue Reading

    CVE-2025-1000 – IBM Db2 Denial of Service due to Improper Automatic Client Rerouting

    Common Vulnerabilities and Exposures (CVEs)

    I thought a privacy screen protector was a great idea – until I put one on my Galaxy S25 Ultra

    News & Updates

    5 SaaS Misconfigurations Leading to Major Fu*%@ Ups

    Development

    Specialized Solutions: Leveraging SDKs for Enhanced Development

    Development

    Highlights

    News & Updates

    US and China agree to pause most tariffs for 90 days — how will this affect tech prices?

    May 12, 2025

    The United States and China have agreed to pause most tariffs for 90 days. The…

    Scrolling using the same code is working 7/10 times

    May 13, 2024

    Robot Interviewers: Welcome to the Future

    April 15, 2024

    10 Large Open-Source Projects Built with Laravel

    July 13, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.