Generate entity files

Workshop Module


When scaffolding a module it will ask which entities you would like to have generated. This is useful however it can happen that you didn't think of one during the scaffolding.

One option would be to create all necessary files manually, or using the following command have them all generated for you.


Using the following artisan command will generate all files and classes for entered entity.

php artisan asgard:entity:scaffold <entity> <module>

First argument is the entity you'd like to add, and second the module to which it needs to be added.

If you want to add a Category entity to the Recipe module this would be your command:

php artisan asgard:entity:scaffold Category Recipe

This will generate all following files :

  • The Category and CategoryTranslation entities,
  • The migration files for both entities,
  • Admin controller class,
  • Admin routes,
  • Permissions,
  • Repository (interface + eloquent implementation + cache decorator + binding in service provider),
  • Views,
  • Language file,
  • Adding link to Sidebar class.


For AsgardCMS to know where to append certain data, it needs to have the original comments in the files generated by the module scaffold.

  • // add bindings in the module service provider,
  • // append in the adminRoutes.php file,
  • // append in the permissions.php config file,
  • // append in the Sidebar class.

Omitting those comments will simply mean those parts won't be generated.

Mobile Analytics