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

Hasin Laravel Package

biiiiiigmonster/hasin

biiiiiigmonster/hasin brings recursive "has in" relationship queries to Laravel's Eloquent ORM, letting you fetch ancestors, descendants, and other nested tree data with fluent, hasMany-style syntax instead of raw recursive SQL. Ideal for category trees, comment threads, and org charts.

View on GitHub
Deep Wiki
Context7

The 'hasin' is an imitator of 'has' in laravel orm relationships, but it's faster.

Frequently asked questions about Hasin
What is biiiiiigmonster/hasin and how does it differ from Laravel whereHas?
biiiiiigmonster/hasin is a query-layer helper for Laravel Eloquent that imitates has and whereHas relationship filtering but rewrites correlated EXISTS subqueries into where ... in (select ...) form. It is aimed at recursive or nested relationship queries such as ancestors, descendants, category trees, comment threads, and org charts. It is additive to Eloquent and does not replace the ORM or require schema changes.
How do I install biiiiiigmonster/hasin in a Laravel app?
Install it with Composer using composer require biiiiiigmonster/hasin, then adopt the whereHasIn-style methods in targeted query builders. The package is a developer-facing query helper and does not imply migrations or config publishing. Check the v5.1.0 composer constraints first if your app runs an older PHP or Laravel baseline.
Which Laravel and PHP versions does biiiiiigmonster/hasin support?
The v5.1.0 release notes include Laravel 13.x compatibility, but the exact composer.json minimum PHP and supported Laravel range are not confirmed in the provided assessment. Check the package composer.json and CI matrix before adding it to an existing app. Do not assume Laravel 10, 11, or 12 remain supported in the same branch without verifying.
How do I use whereHasIn for recursive category trees or descendants?
Use whereHasIn where you would otherwise use whereHas on a relationship that represents tree structure, such as a category parent-child relation or comment thread ancestry. It lets you express ancestor, descendant, and nested-tree filters with fluent hasMany-style syntax instead of hand-written recursive SQL. Validate the generated SQL and row parity against your existing whereHas query for each tree shape.
Can whereHasIn replace whereHas everywhere?
No. whereHasIn is a targeted optimization, not a drop-in replacement for every whereHas call. It is a poor fit when the inner query result set is large or non-selective, when the optimizer already handles EXISTS well, or when you rely on a whereHas closure adding ordering, limits, or aggregates to the inner query. Adopt it per query after benchmarking and correctness checks.
Does hasin work correctly with soft deletes, global scopes, and polymorphic relations?
Treat semantic equivalence as something to test, not assume. IN (subquery) and EXISTS (subquery) are generally equivalent for these predicates, but NULL handling in the correlation, asymmetric global scopes, soft deletes, and polymorphic relations can cause silent row-count differences. Add parity tests for those cases before replacing existing whereHas queries.
Is biiiiiigmonster/hasin faster than Laravel whereHas?
It can be faster when a large parent table is filtered through a selective relationship and the correlated EXISTS plan is the bottleneck. Gains are workload-dependent and can invert on low-selectivity relationships or where the database planner already turns EXISTS into an efficient semi-join. Benchmark with EXPLAIN on production-shaped data and treat the package as a candidate optimization, not an automatic upgrade.
How should I test whereHasIn for row parity and correctness?
For each call site, capture before-and-after EXPLAIN output on production-shaped data and assert row parity with the whereHas query it replaces. Include edge cases such as soft-deleted rows, global scopes, NULL correlation values, and polymorphic relations. Keep these tests in your application suite so future Laravel or package upgrades expose semantic drift.
Is biiiiiigmonster/hasin production-ready and actively maintained?
It is a focused, Composer-installable query helper with no migrations, queue, event, or cache surface, so integration risk is contained if you adopt it per query. The main production concerns are coupling to Eloquent internals and a small, effectively single-maintainer bus factor. Use it behind a thin abstraction or a small set of repository classes so it is replaceable, and pin versions deliberately.
What are alternatives to biiiiiigmonster/hasin for recursive Laravel queries?
Alternatives include native Eloquent whereHas and whereDoesntHave, hand-written recursive CTEs or raw SQL, and tree-structure patterns such as closure tables or nested sets. The right choice depends on whether you need a small per-query optimization or a broader tree-query design. Compare query plans and row-parity tests before switching.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo