ronnytorresmtz/comments
A Laravel package that adds polymorphic commenting to your Eloquent models. Attach comments to any model via a simple trait, with migrations, configuration, and a clean API for creating, retrieving, and managing comments.
composer require the package, then publish its config and migrations (php artisan vendor:publish --provider="...CommentsServiceProvider") and run php artisan migrate.showOnlyMyComments() and allowToShowAllCompaniesComments() — that class is where all visibility logic lives.fields() method for a standard (non-admin) user. Out of the box they should see and manage only their own comments on the records they can already reach.App\Nova\Resources\BaseResource that calls showOnlyMyComments(! $user->isSystemAdmin()) once, then have tenant resources extend it. Otherwise every new resource is a chance to reintroduce the wrong default.allowToShowAllCompaniesComments() in a policy or Gate check (e.g. $user->can('viewAllCompaniesComments')) so it is testable and auditable, rather than scattering hasRole('admin') calls.fields() and do not toggle them conditionally later in the same request, or the last call wins in a way that is hard to trace.showOnlyMyComments() previously ignored its argument and always behaved as if true were passed. Any code calling showOnlyMyComments(false) before this release was silently getting the filtered behavior; after upgrading it will actually show the wider set. Audit every call site before deploying — on a multi-tenant install this is a potential cross-company data exposure, not just a cosmetic change, and the fix is not marked as breaking.allowToShowAllCompaniesComments() is a tenant boundary crossing. It exists for a system-admin user, per the release notes, and it is not self-authorizing. If it is reachable from a resource that ordinary tenant users can load (shared base class, inherited config), you have widened visibility for everyone. Gate it and add a test that a non-admin still sees the scoped list.dd() the underlying query constraints when a user sees the wrong rows. Because the flags mutate query state, confirm the final query rather than the call order in your code.showOnlyMyComments bug survived several releases, so do not assume the flag is honored until you have asserted it. A cheap smoke test that a second user in the same company cannot see the first user's comment will catch this class of bug permanently.composer.json to 1.0.8 or later once verified, so an environment does not sit on a pre-fix build where the boolean argument is silently ignored.How can I help you explore Laravel packages today?