Pages · Laravilt
Component
The abstract base class for Laravilt UI components.
Laravilt\Support\Component is the abstract base class for Laravilt UI components. It uses every trait in Concerns and implements Arrayable, Jsonable, Buildable and Serializable.
Creating a component
Generate a component class and its Blade view:
bash
This creates app/Components/RatingInput.php and resources/views/components/rating-input.blade.php. Add --force to overwrite existing files.
php
make(string $name) resolves the class from the container, sets the name and calls setUp().
Methods
| Method | Returns | Description |
|---|---|---|
make(string $name) | static | Create an instance (static) |
getName() | string | Component name |
meta(array $meta) | static | Merge extra metadata |
getMeta() | array | Metadata |
render() | string | Render $view to HTML (empty when hidden) |
toLaraviltProps() | array | Props for the Inertia frontend |
toApiProps() | array | Props for REST APIs |
toFlutterProps() | array | Props for Flutter clients |
toArray() / toJson() | array / string | Serialize |
Serialized props
toLaraviltProps() returns:
php