Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

User Field Type Laravel Package

anomaly/user-field_type

User field type for the Anomaly Streams platform (PyroCMS). Adds a user-select field to your forms and modules so editors can pick one or more registered users by name; stores their IDs for later lookup and display.

View on GitHub
Deep Wiki
Context7

Getting Started

This is a Streams Platform field type addon, not a standalone Laravel package. It only makes sense inside a PyroCMS/Streams installation (it extends Anomaly\Streams\Platform\Addon\FieldType\FieldType and reads from the users module). If you are not already running the Streams Platform, this package will do nothing for you.

Minimal steps:

  1. Install alongside the platform (it is normally pulled in transitively, but explicitly):
    composer require anomaly/user-field_type
    
  2. Ensure the anomaly/users-module is installed and enabled — the field type sources its dropdown from Anomaly\UsersModule\User\UserModel / the users repository.
  3. Clear caches so the addon is discovered:
    php artisan addon:reload
    php artisan cache:clear
    
  4. The field type now appears as User in the field-type picker when adding a field to a stream (Admin → Streams → Fields → New Field), and is available via slug anomaly.field_type.user.

First use case: add a user field to a stream (e.g. an "Articles" stream with an "Author" field) so editors pick an existing user from a dropdown rather than typing an ID.

Implementation Patterns

Assigning via stream migrations (the reproducible way). Prefer defining the field in your addon's migrations/ so it is version-controlled rather than clicked together in the admin:

$fields = $this->schema->fields();
$fields->add('author', 'anomaly.field_type.user');
$stream = $this->streams->streams()->create('articles', 'Anomaly\ArticlesModule\Article\ArticleModel');

Rendering in a form. Once the field is attached to a stream, the Streams form builder wires it in automatically:

{{ form('articles')->fields('author')->get() }}

Reading the value. The field type returns the related user object, so you can use it directly in Eloquent/Presenter contexts:

$article->author;              // UserInterface|null
$article->author->display_name;

Constraining options. Typical config options on the field type let you restrict or label the select (e.g. a specific user "field"/column used as the option label, and role filtering where supported). Set these per-field in the admin config JSON or via migration ->setConfig([...]).

Multiple selection. Where the underlying select pattern is supported, set multiple config to allow assigning several users (useful for "assignees", "watchers").

Pairing with access control. A common workflow is to use a user field as the owner of a record and then scope queries or presenters against auth()->user() for "my items" views.

Extension point. To change how users are fetched (e.g. only active users, only a tenant), the reliable path is to subclass and override the option-collection method, then register your subclass as its own field type — the base class is small and meant to be extended.

Gotchas and Tips

  • Not standalone. Every failure mode on a non-Streams app ("class not found", field type never appears) traces back to missing anomaly/streams-platform. Confirm the platform boots before debugging this package.
  • Users module is a hard dependency. No users module → empty dropdown. Check php artisan addon:list | grep users.
  • Scales badly. It builds the dropdown from the whole user table; on installations with thousands of users the form becomes slow and the select unusable. There is no AJAX search in this field type — for large user bases roll your own select2-style field type or limit the query.
  • Permission semantics. A user dropdown exposes user records to anyone who can edit the form. Don't use it as a security boundary; enforce authorization in your presenter/policy, not by hiding options.
  • Value is an object, not an ID. Don't do $model->author == $userId; compare $model->author->id (and null-check — the field is often nullable).
  • Config quirk. Option-label config points at a user column; pointing it at a non-existent column yields blank labels rather than an error, which is a slow bug to spot. Verify the column exists on users.
  • Cache/discovery. After composer require or moving the package, field types won't register until php artisan addon:reload (or a full cache clear). This is the #1 "I installed it and nothing happened" cause.
  • Version drift. With 0 stars and effectively no community, expect it to lag platform upgrades and PHP versions. Pin your platform version and test upgrades; treat this as vendored code you may need to patch.
  • Migrations over clicking. Defining the field in migrations/ makes schema reproducible across environments — critical given you can't rely on upstream fixes for anything you discover.
  • Debugging tip. If the field renders as a plain text input, the field type slug in your migration doesn't resolve — re-check the exact slug anomaly.field_type.user and that the addon is enabled.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names