visiosoft/integer-field_type
An integer field type addon for Visiosoft Streams that adds whole-number fields to Laravel-powered CMS entries, forms, and modules. Configure and store numeric values with a simple, lightweight integration designed for Streams Platform projects.
This is not a standalone Laravel package — it is a Streams Platform (PyroCMS 3) field type addon. It will do nothing in a plain Laravel app. Confirm first that your project already pulls in anomaly/streams-platform (or a Visiosoft/OpenClassify distribution) before installing.
Minimal steps:
composer require visiosoft/integer-field-type (check whether your app expects the openclassify/integer-field_type fork — they are the same addon lineage; do not install both).composer.json / extra metadata). If discovery is disabled in your install, register Visiosoft\IntegerFieldType\IntegerFieldTypeServiceProvider manually.php artisan streams:compile, then php artisan view:clear).$stream->addField('stock', 'integer', [
'required' => true,
]);
Where to look first:
src/IntegerFieldTypeServiceProvider.php — registration, config merging, view namespace.src/IntegerFieldType.php — the field type class: $inputView, $presenter, $modifier, rules, config defaults.resources/views/ — the Twig input partial actually rendered in forms.resources/config/settings.php (if present) — per-field configurable options.resources/lang/en/addon.php — the name/description shown in the field picker.First realistic use case: a numeric attribute on a stream entry (quantity, sort order, year, external ID) that you want validated as a whole number in the admin form and cast to int when read back from the entry model.
Declaring fields in migrations/seeders. The normal day-to-day path is addField() on a stream assignment. Use the field type slug (integer) rather than the class name. Assignments belong to a stream, so create the stream first, then add the field, then the namespace/stream is ready for entries.
Per-field configuration. Streams field types expose options through config (commonly min, max, default, step, and sometimes pattern). Set them in the third argument of addField() or in the admin field form. Keep validation in config rather than scattered in controllers — the field type's getRules() is where the platform reads them during form submission.
Reads and writes through the entry model. On the Eloquent side the attribute comes back as the stored column value. If you use a presenter for display, that is where you format (thousands separators, suffix). Keep the raw accessor numeric for calculations and comparisons; format only at render time.
Frontend forms (Twig). Once the field is on a stream and the form builder includes it, {{ form.fields.stock }} (or the generated field set) renders the addon's input view. To customise the markup, publish/override the view under your theme's resources/views with the same namespace path rather than editing the vendor copy.
API / programmatic writes. Treat it like any integer column: cast before saving if you are going through a repository that does not run form validation ($entry->stock = (int) $request->input('stock')). Validation rules from the field type only run in the Streams form flow, not in arbitrary Eloquent saves.
Querying and sorting. For sortable/admin lists, use the standard Streams criteria/query builder against the column; integer comparison is straightforward, but remember nulls sort differently across drivers.
Extending. Two common extension points: subclass the field type and override getRules()/getConfig() (then register your subclass in your own addon), or override the Twig input view. For one-off validation needs, prefer a custom rule in the field config over forking the package.
FieldType base class methods (getRules, getConfig, getModifier, getPresenter) still match what this addon calls.visiosoft/integer-field_type and openclassify/integer-field_type share the same class namespace. Composer may resolve both without complaint while the platform registers a duplicate/wrong provider. Check composer show and your compiled addons list if the field picker behaves oddly."42", not 42. Any === 0 or is_int() check downstream will fail. Cast at the boundary.0 vs empty. Required validation plus a 0 value is a classic false-negative if any custom code uses empty(). Use is_null()/strict checks. Same trap for nullable fields where 0 and null must be distinguished in the DB.unsigned column. Add the column-level guarantees yourself if the data matters (e.g. a separate migration or stream config), especially for negative/leading-zero edge cases.php artisan streams:compile, php artisan view:clear, and if you use a compiled addon manifest, clear it. Most "field type not found" reports are stale cache, not broken code.php artisan addon:list (or your platform's equivalent), that the field assignment exists on the stream, and that the Twig namespace from the service provider is registered. Log the field type class name from the assignment to confirm the slug resolved to this addon.How can I help you explore Laravel packages today?