z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.15k stars 2.82k forks source link

Is Seeder required for releases to other environments? #5706

Open yuki12321 opened 1 year ago

yuki12321 commented 1 year ago

Description:

laravel-admin is very useful. Thanks for your great contribution.

Excuse my rudimentary question. I looked for a similar question but couldn't find it with my help.

I would like to release menus created locally to other environments. If this is to be accomplished, is it correct that a Seeder needs to be created and run at release time? This time we want to release title as Manager and Feature. The menu content is soft coded in the admin_menu table, is there any way to hard code this for release? (I would like to know if there is a way to prevent Seeder from omitting to create/update/delete them)

mysql> select * from admin_menu;
+----+-----------+-------+---------------+--------------+------------------+------------+---------------------+---------------------+
| id | parent_id | order | title         | icon         | uri              | permission | created_at          | updated_at          |
+----+-----------+-------+---------------+--------------+------------------+------------+---------------------+---------------------+
|  1 |         0 |     1 | Dashboard     | fa-bar-chart | /                | NULL       | NULL                | NULL                |
|  2 |         0 |     2 | Admin         | fa-tasks     |                  | NULL       | NULL                | NULL                |
|  3 |         2 |     3 | Users         | fa-users     | auth/users       | NULL       | NULL                | NULL                |
|  4 |         2 |     4 | Roles         | fa-user      | auth/roles       | NULL       | NULL                | NULL                |
|  5 |         2 |     5 | Permission    | fa-ban       | auth/permissions | NULL       | NULL                | NULL                |
|  6 |         2 |     6 | Menu          | fa-bars      | auth/menu        | NULL       | NULL                | NULL                |
|  7 |         2 |     7 | Operation log | fa-history   | auth/logs        | NULL       | NULL                | NULL                |
|  8 |         0 |     0 | Manager       | fa-bars      | manager          | NULL       | 2022-12-30 10:37:13 | 2022-12-30 10:37:13 |
|  9 |         8 |     0 | Feature       | fa-bars      | manager/features | NULL       | 2022-12-31 18:59:16 | 2022-12-31 18:59:16 |
+----+-----------+-------+---------------+--------------+------------------+------------+---------------------+---------------------+
9 rows in set (0.00 sec)

Steps To Reproduce:

alexoleynik0 commented 1 year ago

Not sure if that's correct use of Seeders 🤔 Try migrations maybe? They can be used not only to alter DB tables, but to insert essential data too, no big shame in that. Look in the laravel-admin migrations in your project's database/migrations directory for inspiration.