Download the PHP package dev-lnk/moonshine-builder without Composer
On this page you can find all versions of the php package dev-lnk/moonshine-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package moonshine-builder
Generate code using JSON schema, SQL tables, and console commands for MoonShine.
Table of contents
- Description
- Installation
- Configuration
- Generate code using JSON or MYSQL
- Creating a JSON schema
- Timestamps
- Soft deletes
- Flags for generating files
- Creation from SQL table
- Bulk table import
- Generating code using console command
- Specifying fields in the command
- List of field types
Description
Hello, Laravel and MoonShine User!
This package allows you to describe the entire project structure using a JSON table schema, SQL
table, console command and generate the necessary files such as:
Installation:
Configuration:
Publish the package configuration file:
In the configuration file, specify the path to your JSON schemas:
Generate code using JSON or MYSQL
Now you can run the command:
You will be given options as to which scheme to use when generating the code, for example:
Creating a JSON schema
In the builds_dir
directory, create a schema file, for example, category.json
:
To generate project files, run the command:
A more detailed example with multiple resources and relationships can be found here. For hints in your IDE or for a more detailed description of the JSON structure, you can use this file.
Timestamps
You can specify the timestamps: true
flag
The created_at
and updated_at
fields will be added to your code. If you manually specified the created_at
and updated_at
fields, the timestamps
flag will be automatically set to true.
Soft deletes
Works similarly to the timestamps
flag and the deleted_at
field.
Flags for generating files
Using flags withResource
, withModel
, withMigration
, you can configure what exactly you want to generate for your resource:
Creation from SQL table
You can create a resource using a table schema. You must specify the table name and select table
type. Example:
Result:
After generating the files, make sure to register all new Resources in your MoonShineServiceProvider
.
Bulk table import
If you already have a project with its own database and you don't want to build the resources one by one, you can use the following command:
First, select all your Pivot tables to correctly form the BelongsToMany relationship, then select all the necessary tables for which you want to generate resources.
A JSON schema will be generated, which you can edit and apply if desired.
Generating code using console command
To generate the resource, model, and migration, run the command:
Specify all required fields:
Once all fields have been specified, generate the code
Specifying fields in the command
You can also specify all fields at once in the command, ignoring the interactive mode:
The structure of the value has the following scheme: <column>:<column name>:<type>
If the field type is relation, the structure is as follows: <column>(name of the relationship method in the model):<column name>:<type>:<table>
List of field types
The list of field types can be retrieved using the command: