Generate a resource with the Scaffolder
Describe a new list-and-form screen (its module, name and fields), preview every file the generator would write, then write them from the screen or with the matching command.
- Applies to
- Stub Generator 1.0 and later
- Who can do this
- Developer
- Permission
feature.stubgen. scaffolder. generate - Where
- Scaffolder (Platform Administration)
On this page
A resource is one kind of record in a module, with its list, form and detail screens, permissions, menu entry and tests. The Scaffolder screen builds all of it from a short description, using the same generator as Core's php artisan laramin:make- command.
Danger: Generate writes files into the code of the Laramin you're signed in to, on its server. Use it only on a development copy that's under version control, never on your live Laramin. Review the files and commit them like any other code change.
Before you start
- The module must already exist in
Modules/. To start one, see Create a new module shell. - You need Use Scaffolder (
feature.) to open the screen and preview. Writing files also needs Generate Scaffold (stubgen. scaffolder.view feature.). Without it, the Generate button isn't shown and you can only preview.stubgen. scaffolder. generate - The web server must be able to write to the module's folder.
Steps
-
In the Platform Administration sidebar, select Scaffolder. The Vue CRUD Scaffolder screen opens in Resource mode.
-
Under Blueprint, fill in:
- Module: the module's folder name, such as
Inventory. - Entity: the record's name, singular, such as
Item. - Abbreviation: optional. The module's permission abbreviation, used in permission keys such as
feature.. Leave it empty to use the module's own.inv. item.list
- Module: the module's folder name, such as
-
Set the switches: Soft deletes, Gated (policy), Read-only and Factory. The first two are on to start with. See Scaffolder fields, options and generated files.
-
Under Fields, describe each field. A
titlefield is already there.-
Select Add field.
-
Enter its Name in lowercase, with underscores, such as
unit_price. -
Choose its Type.
-
For a belongsTo field, enter the Related model. For a select field, enter its Options, separated by commas.
-
Tick Nullable or Unique if needed. Open Advanced to choose where the field appears and whether it can be searched, sorted or filtered.

-
-
Select Preview. The Preview card lists every file, with a count, and shows the contents of the file you choose under File.

-
Check the preview. Change the blueprint and select Preview again until it's right.
-
To write the files, select Generate. To replace files that already exist, turn on Overwrite existing files first.
-
In Generate files, select Generate.

The Result card shows Files generated successfully., or Generated with warnings — review the result below., with the number of files written and skipped. Existing files are skipped unless you chose to overwrite them. Each new PHP file is checked for syntax errors, and any are listed under Syntax errors in generated files.
Tip: You don't have to write from the screen. The line under the buttons, Preview only — write the files with the CLI:, shows the matching php artisan laramin:make- command for your blueprint. Run it on your development copy instead.
What happens next
The new screen doesn't appear until you finish the Next steps the Result card lists. Run these on the server, in your Laramin's folder:
php artisan module:migrate Inventory, with your module's name, to create the table.php artisan permission:sync --module=Inventory --forceto add the new permissions.php artisan optimize:clear.- Add the menu entry. No command rebuilds the menu on its own; see The Scaffolder shows warnings, or what it made doesn't appear for how to add it.
Then give the new permissions to the roles that need them. See Give someone a role.
If it doesn't work
For warnings in the result, skipped files, or a screen that doesn't appear, see The Scaffolder shows warnings, or what it made doesn't appear.
- "Module [Inventory] does not exist on disk." Create the module first, then generate the resource into it.
- Preview or Generate can't be selected. Fill in Module and Entity, and give every field a name.
- "Could not build the preview." The message under it names the problem, such as an unknown field type. Module and entity names must start with a letter and use only letters and digits. Field names must start with a lowercase letter and use only lowercase letters, digits and underscores.
Thanks. That helps us decide what to write next.
Thanks for telling us what was missing.
You already answered for this article today. Thanks.
We got a lot of answers from your network just now. Try again in a few minutes.
We couldn't send that. Check your connection and try again.
Links in this article
Printed from help.laramin.in. The online article may have changed since.