staudenmeir/eloquent-has-many-deep-contracts
Contracts for staudenmeir/eloquent-has-many-deep. Includes the ConcatenableRelation contract to make third-party relationship packages concatenable with HasManyDeep, improving interoperability when combining deep Eloquent relations.
This package provides only interfaces—no concrete implementation. Start by installing it via Composer:
composer require staudenmeir/eloquent-has-many-deep-contracts
Then locate the primary contract: Staudenmeir\EloquentHasManyDeep\Contracts\HasManyDeepContract. This interface defines the minimal contract for deep hasMany relationships (e.g., Post → User → Comments). Use it to type-hint in your own classes or test doubles.
First use case: Type-hint the contract in your repository or service classes to accept any implementation of HasManyDeep, e.g., HasManyDeep, HasManyDeepThroughPivot, etc.
HasManyDeepContract to accept multiple implementations (e.g., for testing or futureSwap).
public function __construct(protected HasManyDeepContract $postsWithComments) {}
PostRepository that accepts contracts, letting you swap implementations (e.g., native HasManyDeep, custom caching wrapper) without breaking consumers.Mockery::mock(HasManyDeepContract::class).HasManyDeepContract to ensure compatibility with community implementations (e.g., staudenmeir/eloquent-has-many-deep, future forks, or internal variants).staudenmeir/eloquent-has-many-deep) in your app.AppServiceProvider if injecting the contract:
$this->app->bind(HasManyDeepContract::class, HasManyDeep::class);
where and with") since the interface alone doesn’t enforce them.How can I help you explore Laravel packages today?