Skip to content

Commit 0e81369

Browse files
committed
support for two grammar constructor types
1 parent 92c29e8 commit 0e81369

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Services/FileMakerConnection.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,21 @@ public function setTimeout($timeout)
874874

875875
protected function getDefaultQueryGrammar()
876876
{
877-
return new FMGrammar;
877+
// check if this is laravel 11 or 12
878+
// Laravel 11 constructs a grammar without any parameters
879+
// Laravel 12 requires a connection as a constructor parameter
880+
881+
$reflectionMethod = new \ReflectionMethod(FMGrammar::class, '__construct');
882+
$parameterArray = $reflectionMethod->getParameters();
883+
884+
if (count($parameterArray) === 0) {
885+
// Laravel 11 and earlier
886+
return new FMGrammar;
887+
}
888+
889+
// Laravel 12
890+
return new FMGrammar($this);
891+
878892
}
879893

880894
// public function getLayoutMetadata($layout = null)

0 commit comments

Comments
 (0)