pavloniym/nova-matrix-input-field
A Laravel Nova field for matrix-style input, letting you capture grid or tabular values directly in Nova forms. Adds a custom matrix input component for editing structured data, with a simple field API for defining rows and columns in your resources.
Install the field via Composer:
composer require pavloniym/nova-matrix-input-field
The package uses Laravel auto-discovery; no additional service provider registration is normally required. Ensure your project is running a compatible Nova version (check composer.json constraints).
Add the field to a Nova resource:
use Pavloniym\NovaMatrixInputField\MatrixInput;
public function fields(Request $request)
{
return [
MatrixInput::make('Pricing Matrix')
->rows(['Basic', 'Pro', 'Enterprise'])
->columns(['Monthly', 'Yearly']),
];
}
On the Eloquent model, cast the underlying column to an array or JSON so Nova receives structured data:
protected $casts = [
'pricing_matrix' => 'array',
];
Your first use case is typically a fixed grid of editable values—tiered pricing, feature availability by role, shift schedules, or survey responses—stored as a single JSON column.
->rows(Role::pluck('name')->toArray())
->columns(['Read', 'Write', 'Delete'])
Cache or memoize expensive queries if the matrix is large.rules() with dot notation for nested cell validation:
->rules(['matrix.*.*' => 'nullable|numeric|min:0'])
For complex rules, validate in a FormRequest or use ->rulesFor() if the package exposes per-cell hooks.->displayUsing() to render a readable summary on detail and index views instead of raw JSON. For index tables, consider a separate computed field or accessor.->readonly() or ->disabled() when the matrix should be visible but not editable (e.g., audit views).->default([...]) for new records. Pair with ->nullable() if an empty matrix is valid.array or json cast, the field may receive a string or inconsistently shaped data. Double-check the model cast before debugging the Vue component.matrix.*.*). A top-level array rule alone will not validate individual cells.null or []. Use ->nullable() and a default to avoid “array to string conversion” errors.composer.json and review the compare link for Nova constraint changes.php artisan nova:publish and check whether the package requires publishing assets (vendor:publish). Consult the README for the exact tag.__() in the resource or override the field’s Vue component.->resolveUsing() only if you need custom hydration. Avoid manually json_encode-ing values before the field fills the model.MatrixInput in a custom Nova field or override the Vue component rather than modifying vendor files.How can I help you explore Laravel packages today?