whilesmart/eloquent-owner-access
A lightweight Laravel package that adds owner and access-control behavior to Eloquent models, letting you assign owners and authorize who can view, edit, or share records with simple, reusable traits.
owner_type/owner_id and delegates the "who may read/write this" decision to the host app, so the feature does not have to hardcode user vs team vs organization vs tenant.User + Organization owners; marketplaces with buyer/seller-owned records; LMS with school/department/teacher ownership; white-label CMS with brand-owned content; internal tools where ownership is a cost center or project.Adopt (or at least prototype) when all of these hold:
Gate/policy layer rather than in your package.Look elsewhere when:
user_id foreign key plus a Laravel policy is simpler and has zero dependency risk.spatie/laravel-permission or a dedicated ACL, not owner scoping.stancl/tenancy territory; owner columns solve authorization, not isolation.To executives: This is a small MIT-licensed library that lets our packages and features store records against any kind of owner — a user, a team, an organization — and lets each customer's app decide who can see and change those records. The business value is optionality: we can ship owner-scoped features now and add team/workspace ownership later without rewriting our data model or our packages. Cost is near zero (MIT, ~one trait and a contract), and the risk is contained because the code is small and forkable. Recommendation: fund a 1–2 day spike, not a platform-wide commitment. Adoption signals are essentially zero today, so we should pin it, wrap it behind our own interface, and revisit in one quarter.
To engineering: One trait adds polymorphic owner_type/owner_id columns and an owner relation; authorization is not implemented here — it is delegated to a contract the host application binds, so your Gate/policies remain the single source of truth. That keeps our packages tenancy-agnostic and eliminates the "which tenancy package do you support?" support matrix. The trade-offs are the usual ones for polymorphic ownership: no real foreign-key integrity on owner_id, global scopes can be bypassed with withoutGlobalScope, and there is no compiled/indexed tenancy boundary. Mitigate with a composite index on (owner_type, owner_id), an internal adapter class, a version pin, and a fork-and-patch contingency given the license. If we go ahead, the acceptance test is: swap the owner from User to Team in a staging app without touching package code.
How can I help you explore Laravel packages today?