Search code examples
phplaravelacllaravel-permission

Laravel 5.6 - User Roles and Permissions (ACL) using Spatie Tutorial


Can you give me advice what to do. I am following this tutorial: Laravel 5.6 - User Roles and Permissions (ACL) using Spatie Tutorial

All good. But in the end, I have only access to users page and cannot create new user because there are not roles in the list. In the pages - products and roles gives me a message from the handler: ["User have not permission for this page access."]

I have only permission seeds:

    <?php

use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;

class PermissionTableSeeder extends Seeder
{
  /**
   * Run the database seeds.
   *
   * @return void
   */
  public function run()
  {
     $permissions = [
         'role-list',
         'role-create',
         'role-edit',
         'role-delete',
         'product-list',
         'product-create',
         'product-edit',
         'product-delete'
      ];


      foreach ($permissions as $permission) {
           Permission::create(['name' => $permission]);
      }
  }
}

I can give you more code if you wish from the project.


Solution

  • I created a repository I mentioned in comment to setup same thing as the tutorial you mentioned. What I need to do was, I created a role with create-product permission and assign that to one user and from that user credential I could create new product.

    so, in tutorial he has skipped two steps, role creation and assigning role to user before creating product.