> For the complete documentation index, see [llms.txt](https://crudstarter.gitbook.io/crudstarter-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://crudstarter.gitbook.io/crudstarter-docs/customization-via-config.md).

# 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`

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:

```php
'image_fields' => ['image', 'images', 'img', 'pic', 'pics', 'picture', 'pictures', 'avatar', 'photo', 'photos', 'gallery', 'logo', 'logos', 'favicon', 'favicons', 'banner', 'banner_image']
```

In this example, fields like `avatar`, `photo`, `logo`, or `banner_image` will be generated as image fields.

#### `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`

This option specifies the type of the default fallback image path. It can be set to either `'url'` or `'asset'`.

* `'url'`: The `default_image_path` will be treated as a URL (e.g., `'https://picsum.photos/id/237/200/300'`).
* `'asset'`: The `default_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`

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:

```php
'default_image_type' => 'url',
'default_image_path' => 'https://upload.wikimedia.org/wikipedia/commons/a/ac/No_image_available.svg'
```

### Form Configuration

#### `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`

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

<div><figure><img src="https://2199596568-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEK8S3sawwZds4u2XuyZ%2Fuploads%2FemfGXkMiAIay1SvEIGBX%2F4-col.png?alt=media&amp;token=500820d2-3ed9-4a7a-8a8f-54710b3bf44d" alt=""><figcaption><p>4 cols per row</p></figcaption></figure> <figure><img src="https://2199596568-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEK8S3sawwZds4u2XuyZ%2Fuploads%2FOKxdUOyxQCp5n1zvmUbe%2F2-col.png?alt=media&amp;token=43c64fbf-f09a-43d6-95f5-1e5969d8a2e5" alt=""><figcaption><p>2 cols per row</p></figcaption></figure></div>

### Routing Configuration

#### `crud_route`

This option specifies the default route file (e.g., `'web.php'`) where the CRUD routes will be generated.

#### `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.
