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
Laravel Ownable

Laravel Ownable Laravel Package

santigarcor/laravel-ownable

A Laravel package that adds polymorphic ownership to Eloquent models, letting any model be assigned to users or other entities. It provides traits, relationships, and helpers to query owned records and manage ownership across your application.

View on GitHub
Deep Wiki
Context7

This trait allows you to check if a model owns some other model in your Laravel application.

Frequently asked questions about Laravel Ownable
How do I install santigarcor/laravel-ownable in a Laravel app?
Run composer require santigarcor/laravel-ownable, add nullable owner_type and owner_id columns to the model that will be owned, and apply the package trait to that model. Then configure your morph map so owner types resolve consistently. Installation is low effort and a proof of concept typically takes hours rather than weeks.
Which Laravel and PHP versions does laravel-ownable support?
The package's last release was December 2023, so verify its Composer constraints against your current Laravel and PHP matrix before adopting it. Test against the next Laravel major as part of your upgrade process. Pin the version and keep an in-house fallback if constraints fail.
How do I check if one model owns another model in Laravel?
The trait exposes ownership relationships and helper methods so you can query whether a given model owns another Eloquent record. Use these helpers with eager-loaded ownership relations in hot paths. Keep in mind these are ownership checks, not authorization decisions.
Do I need to add owner_type and owner_id columns for laravel-ownable?
Yes. Add nullable owner_type and owner_id columns to the owned model's table and back them with a composite index. Backfill ownership data only where the semantics are well understood. Confirm morph-map conventions before rolling the schema out.
Can laravel-ownable handle multiple owners or shared ownership of a record?
No, the package is built around single-owner semantics for generic model-to-model ownership. Multi-owner sharing, delegated ownership, and hierarchical permissions belong in policies, gates, or a dedicated ACL package. Choose a different tool if shared ownership is a core requirement.
What happens to owned records when the owner is deleted in laravel-ownable?
The package itself does not enforce cascade behavior, so deleting an owner can leave orphaned ownership records. Handle this with foreign-key constraints where practical, model events, or an explicit transfer-and-audit workflow. Write tests that cover owner deletion.
Is laravel-ownable a replacement for Laravel policies and gates?
No. Ownership checks answer which model owns this record, while authorization policies decide whether a user may perform an action. Use laravel-ownable alongside policies and gates, never as a substitute. Treat ownership as data, not as an authorization boundary.
How do I configure morph maps for laravel-ownable?
Register a morph map in a service provider so owner_type values remain stable and readable. Keep the map consistent across the application, because changing it later can orphan existing ownership rows. Document the convention so every team follows it.
How do I test ownership behavior with laravel-ownable?
Write integration tests that create records via factories, attach owners of different types, and assert the ownership helpers return the expected results. Cover owner deletion, transfer, and morph-map changes. Run the suite on every supported database.
Is laravel-ownable still maintained, and what is the fallback?
The package has a single maintainer, modest adoption, and its last release was December 2023, so treat it as a source-level utility rather than a strategic dependency. Pin the version, assign an internal owner, and monitor upstream activity. If it becomes abandoned or incompatible, fork the small trait into your application code.
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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console