/home/techb158/ileadtechnology.com/vendor/spatie/laravel-query-builder/src
Edit: /home/techb158/ileadtechnology.com/vendor/spatie/laravel-query-builder/src/AllowedInclude.php (2526B)
name = Str::camel($name);
$this->includeClass = $includeClass;
$this->internalName = $internalName ?? $this->name;
}
public static function relationship(string $name, ?string $internalName = null): Collection
{
$internalName = Str::camel($internalName ?? $name);
return IncludedRelationship::getIndividualRelationshipPathsFromInclude($internalName)
->zip(IncludedRelationship::getIndividualRelationshipPathsFromInclude($name))
->flatMap(function ($args): Collection {
[$relationship, $alias] = $args;
$includes = collect([
new self($alias, new IncludedRelationship, $relationship),
]);
if (! Str::contains($relationship, '.')) {
$suffix = config('query-builder.count_suffix');
$includes = $includes->merge(self::count(
$alias.$suffix,
$relationship.$suffix
));
}
return $includes;
});
}
public static function count(string $name, ?string $internalName = null): Collection
{
return collect([
new static($name, new IncludedCount(), $internalName),
]);
}
public function include(QueryBuilder $query): void
{
if (property_exists($this->includeClass, 'getRequestedFieldsForRelatedTable')) {
$this->includeClass->getRequestedFieldsForRelatedTable = function (...$args) use ($query) {
return $query->getRequestedFieldsForRelatedTable(...$args);
};
}
($this->includeClass)($query->getEloquentBuilder(), $this->internalName);
}
public function getName(): string
{
return $this->name;
}
public function isForInclude(string $includeName): bool
{
return $this->name === $includeName;
}
}