CRUD Generator command
CRUD Generator allows you to easily generate CRUD for existing table. It will generate:
- Model class
- Controller class
- Request classes
- Routes
- Vue files for listing and form
- Typescript definitons
- API endpoints
- Export class
Usage
We support two ways of generating CRUD. Using command with user-friendly wizard which will guide you through the process, or using YAML config generation.
To use wizard mode, you can either run the command with only -w
or --wizard
arguments like this:
php artisan craftable-pro:generate-crud -w
Or you can specify table_name
parameter option like so:
php artisan craftable-pro:generate-crud {table_name} -w
Alternatively you can run the command without the wizard mode. It will read the database schema generate the CRUD by guessing the desired options:
php artisan craftable-pro:generate-crud {table_name}
table_name
must be an existing tableOptions
--w|wizard
-> Wizard mode asks for most common options interactively--run-migration
-> Whether to run permission migration after generating CRUD or not--without-routes
-> Do not generate routes--without-sidebar
-> Do not append new module into the sidebar--dry-run
-> Display all information without actually generating anything';
Wizard mode
In wizard mode, the generator will prompt you with a series of questions to help you define the options for CRUD generation. Bellow you will find all the questions explained in more detail.
CTRL + U
Listing columns
This option allows you to select columns which will be displayed in the listing.

Sortable columns
This option allows you to select columns which will be sortable in the listing. You can only choose from columns selected in the previous step.

Searchable columns
This option allows you to select columns which will be searchable in the listing. You can only choose from fields selected in the listing columns step.

Form columns
This option allows you to select columns which will be visible in the Vue form.

Translatable columns
This option allows you to select columns which will be translatable. You can only choose from those, which have defined json
or jsonb
type id database.

Publishable columns
This option allows you to select column which will be used for publishable feature. This will generate nice button in listing, with which you can quickly schedule or unpublish certain record. You can only choose from date
or datetime
columns.

Media collections
This option allows you to write names of media collection you want to register for your model.

Image collections
This option allows you to select which of the media collection you want to use as an image collections.

Relations
This option allows you to define relationships on your model. Defining relationship consist of multiple steps, so please take a look at the example bellow to get the idea about which question you can expect. Bear in mind that some of them might change depending on your choices.







Layout
This option allows you to define the number of columns for your form layout.

If you decide to use multiple columns, you will be prompted to select fields for every column.


API endpoints
This option allows you to define what API endpoints you want to generate.

Then you will be prompted to select fields for every API endpoint.

Export
This option allows you to define if you want to generate export of your records to excel.

Dry run
This option allows you to see outocome of your choices without actually generating or changing any files. You have to specify it when running the command itself:
php artisan craftable-pro:generate-crud -w --dry-run