Customization via Config
The CRUD Generator package provides a configuration file to customize various aspects of the generated CRUD operations. This file allows you to set defaults for image field handling, validation rules, form layout, and routing. Here's a detailed explanation of each configuration option:
Image Field Configuration
image_fields
image_fields
This option specifies an array of strings that will be treated as image fields during the CRUD generation process. Any field with a name matching one of these strings will be generated as an image field, enabling file uploads and image handling functionality.
Example:
In this example, fields like avatar
, photo
, logo
, or banner_image
will be generated as image fields.
image_required
image_required
This boolean option determines whether image fields are required or optional during CRUD generation.
true
: Image fields will be required.false
: Image fields will be optional.
default_image_type
default_image_type
This option specifies the type of the default fallback image path. It can be set to either 'url'
or 'asset'
.
'url'
: Thedefault_image_path
will be treated as a URL (e.g.,'https://picsum.photos/id/237/200/300'
).'asset'
: Thedefault_image_path
will be treated as an asset path relative to the public directory (e.g.,'uploaded-images/my-images/hero_image.png'
).
default_image_path
default_image_path
This option specifies the default fallback image path to be used when no image is available. The path should be provided according to the default_image_type
setting.
If
default_image_type
is set to'url'
, provide a valid URL.If
default_image_type
is set to'asset'
, provide the asset path relative to the public directory.
Example:
Form Configuration
default_validation
default_validation
This option determines the default validation rule to be applied to fields during CRUD generation. It can be set to either 'required'
or 'nullable'
.
cols_per_row
cols_per_row
This option specifies the number of columns each row in the form should contain. It affects the layout of the form, making it more organized and visually appealing. If set to 2
, each row in the form will contain two fields, assuming a 12-column grid layout. This means each field will span 6 columns (12 / 2 = 6).
Example: 4 cols_per_row and 2 cols_per_row
Routing Configuration
crud_route
crud_route
This option specifies the default route file (e.g., 'web.php'
) where the CRUD routes will be generated.
api_route
api_route
This option specifies the default route file (e.g., 'api.php'
) where the API routes for the CRUD will be generated.
By customizing these configuration options, you can tailor the behavior of the CRUD Generator package to suit your project's needs, ensuring consistent image handling, form layout, and routing conventions.
Last updated