Skip to content

UnknownModelAttribute: check the two-argument lookup family and incrementOrCreate() #2347

Open

Description

@alies-dev

Is your feature request related to a problem? Please describe.
UnknownModelAttributeHandler deliberately defers the two-argument family (its docblock: updateOrCreate/firstOrCreate/firstOrNew take a lookup map, not a pure write map). Typos in either map are not reported:

Post::updateOrCreate(['slgu' => $slug], ['title' => $t]);
Post::query()->incrementOrCreate(['slgu' => $slug], 'views');

Describe the solution you'd like
Check both maps of firstOrNew, firstOrCreate, createOrFirst, updateOrCreate ($values may be a Closure on newer Laravel: decline then), and incrementOrCreate(array $attributes, string $column = 'count', $default = 1, $step = 1, array $extra = []) including the literal $column and $extra keys. incrementOrCreate() exists on the Eloquent Builder on every supported Laravel version and on HasOneOrMany since 13.35.0 (version gate the relation form). Keep the existing receiver and user-override gates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions