Search code examples
laravellaravel-5voyager

Voyager admin menu isn't shown for user with role "admin" with all permissions


I've created new user by regular "Register" link at app frontend, then issued

php artisan voyager:admin this_user@mail.com

and logged in to Voyager with this user's login and password. What I saw is empty space in the panel on the left instead of admin menu: enter image description here

I've checked roles and permissions in database. In users table this user has role_id set to 1, which is "admin" in table roles and has all permissions in permission_role. This seems to be OK.

Why this user doesn't see the admin menu?


Solution

  • It turns out that two tables were missing from the database: data_rows and data_types. I've recreated them using this:

    CREATE TABLE IF NOT EXISTS `data_types` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `display_name_singular` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `display_name_plural` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `icon` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
      `model_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
      `policy_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
      `controller` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
      `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
      `generate_permissions` tinyint(1) NOT NULL DEFAULT '0',
      `server_side` tinyint(4) NOT NULL DEFAULT '0',
      `details` text COLLATE utf8_unicode_ci,
      `created_at` timestamp NULL DEFAULT NULL,
      `updated_at` timestamp NULL DEFAULT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `data_types_name_unique` (`name`),
      UNIQUE KEY `data_types_slug_unique` (`slug`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
    
    CREATE TABLE IF NOT EXISTS `data_rows` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `data_type_id` int(10) unsigned NOT NULL,
      `field` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `type` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `display_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `required` tinyint(1) NOT NULL DEFAULT '0',
      `browse` tinyint(1) NOT NULL DEFAULT '1',
      `read` tinyint(1) NOT NULL DEFAULT '1',
      `edit` tinyint(1) NOT NULL DEFAULT '1',
      `add` tinyint(1) NOT NULL DEFAULT '1',
      `delete` tinyint(1) NOT NULL DEFAULT '1',
      `details` text COLLATE utf8_unicode_ci,
      `order` int(11) NOT NULL DEFAULT '1',
      PRIMARY KEY (`id`),
      KEY `data_rows_data_type_id_foreign` (`data_type_id`),
      CONSTRAINT `data_rows_data_type_id_foreign` FOREIGN KEY (`data_type_id`) REFERENCES `data_types` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
    

    Then I've seeded them by issuing commands:

    php artisan db:seed --class=DataTypesTableSeeder
    php artisan db:seed --class=DataRowsTableSeeder
    

    Now everything is working fine!