# Props Model & meta

The `Props` model is designed to define various properties that can be associated with products. These properties enhance the characterization of products, enabling users to filter, search, and understand product attributes effectively. Each property can influence inventory management as well.

## Fields

- **id**: 
  - A unique identifier for each property entry. This number is automatically generated by the system to ensure every property can be distinguished from one another.

- **name**: 
  - The name of the property, which serves as a key identifier. It must be unique and should not contain spaces, numbers, or special characters. Once selected, the name cannot be changed. This feature ensures consistency and eases the management of properties.

- **label**: 
  - A descriptive label for the property. This name is displayed to users to provide a clear understanding of what the property represents.

- **width**: 
  - This field specifies the Bootstrap grid size for displaying the property input field. The default value is set to `col-md-6`, allowing for flexible layout in user interfaces.

- **required**: 
  - A boolean field indicating whether this property is mandatory for product listings. By default, it is set to `false`, meaning the property is optional.

- **searchable**: 
  - This boolean field determines if the property can be used in search filters. By default, it is set to `true`, allowing users to search for products based on this property.

- **type**: 
  - Specifies the input type for the property. The user can select from the following options: 
  - **text**: A standard text input.
  - **number**: An input for numeric values.
  - **checkbox**: A boolean option that can be either checked or unchecked.
  - **color**: A color selection input.
  - **select**: A dropdown menu for selecting one option.
  - **multi**: Allows selecting multiple options at once.
  - **singlemulti**: One value is registered during submission, but allows for multiple selections during search.
  - **date**: A date input.
  - **time**: A time input.

- **unit**: 
  - This field indicates the measurement unit for the property (e.g., weight measured in grams). It provides clarity when defining the context of the property.

- **sort**: 
  - An unsigned integer that determines the order in which properties are displayed. This field is optional and can be left null.

- **options**: 
  - A long text field that can contain predefined options for selection-type properties, such as those configured for the `select` input type. This allows for the creation of dropdown menus with specific choices.

- **priceable**: 
  - A boolean field indicating whether this property can affect pricing. It is set to `false` by default.

- **icon**: 
  - A string that specifies an optional icon associated with the property. This can enhance the user interface by providing visual cues.

## Metadata Storage

Unlike traditional models, the `Props` model does not have a pivot table. Instead, when creating or updating a product, properties can be assigned as metadata using the following command:

```php
$product->syncMeta(json_decode($request->get('meta', '[]'), true));
```

This method allows for the dynamic association of properties without requiring an intermediary table.

## Quantities Model

The `Quantities` model is used to manage stock levels for products but will not be elaborated much here. The key takeaway is that properties are stored in the `Quantities` model as JSON, which influences inventory management and related data.

### Fields

- **product_id**:
  - The unique identifier for the product being tracked in terms of quantity.

- **count**:
  - An unsigned integer that indicates the available stock count, defaulting to zero.

- **price**:
  - An unsigned integer for the product price, allowing for financial tracking.

- **image**:
  - This field can store image references for the product and is nullable.

- **data**:
  - Designed to hold additional information or metadata in JSON format, this field is optional and can be left empty.

---

This structure outlines the `Props` and `Quantities` models, emphasizing how properties enhance product details and influence inventory management. The document is designed to be straightforward and comprehensive for users without a technical background.
