Skip to content

Commit

Permalink
Resolve error
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Aug 28, 2024
1 parent 45b29e6 commit 6ccfd4d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ parameters:
- '#Call to an undefined method TModel of Illuminate\\Database\\Eloquent\\Model#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Builder#'
- '#Call to an undefined method Illuminate\\Database\\ConnectionInterface#'
- '#Call to an undefined method Staudenmeir\\LaravelAdjacencyList\\Query\\Grammars\\ExpressionGrammar::wrap\(\)#'
- '#PHPDoc tag \@param for parameter \$grammar with type Illuminate\\Database\\Grammar\|Staudenmeir\\LaravelAdjacencyList\\Query\\Grammars\\ExpressionGrammar is not subtype#'
22 changes: 12 additions & 10 deletions src/Eloquent/Traits/BuildsAdjacencyListQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,39 @@ protected function replacePathSeparator(array $items, $path, $separator)
*/
public function getExpressionGrammar()
{
$driver = $this->query->getConnection()->getDriverName();
/** @var \Illuminate\Database\Connection $connection */
$connection = $this->query->getConnection();

switch ($driver) {
switch ($connection->getDriverName()) {
case 'mysql':
$grammar = $this->query->getConnection()->isMaria()
/** @var \Illuminate\Database\MySqlConnection $connection */
$grammar = $connection->isMaria()
? new MariaDbGrammar($this->model)
: new MySqlGrammar($this->model);

return $this->query->getConnection()->withTablePrefix($grammar);
return $connection->withTablePrefix($grammar);
case 'mariadb':
return $this->query->getConnection()->withTablePrefix(
return $connection->withTablePrefix(
new MariaDbGrammar($this->model)
);
case 'pgsql':
return $this->query->getConnection()->withTablePrefix(
return $connection->withTablePrefix(
new PostgresGrammar($this->model)
);
case 'sqlite':
return $this->query->getConnection()->withTablePrefix(
return $connection->withTablePrefix(
new SQLiteGrammar($this->model)
);
case 'sqlsrv':
return $this->query->getConnection()->withTablePrefix(
return $connection->withTablePrefix(
new SqlServerGrammar($this->model)
);
case 'singlestore':
return $this->query->getConnection()->withTablePrefix(
return $connection->withTablePrefix(
new SingleStoreGrammar($this->model)
);
case 'firebird':
return $this->query->getConnection()->withTablePrefix(
return $connection->withTablePrefix(
new FirebirdGrammar($this->model)
);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Eloquent/Traits/HasGraphRelationshipScopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ protected function addInitialQueryPivotColumns(
$columns = [$this->getParentKeyName(), $this->getChildKeyName(), ...$this->getPivotColumns()];

if ($initialDepth === 0) {
$columnDefinitions = (new Collection($query->getConnection()->getSchemaBuilder()->getColumns($pivotTable)))
/** @var \Illuminate\Database\Connection $connection */
$connection = $query->getConnection();

$columnDefinitions = (new Collection($connection->getSchemaBuilder()->getColumns($pivotTable)))
->keyBy('name');

foreach ($columns as $column) {
Expand Down

0 comments on commit 6ccfd4d

Please sign in to comment.