Skip to content
This repository was archived by the owner on Jul 31, 2018. It is now read-only.

Commit 72d45cb

Browse files
authored
Update AlgoliaEloquentTrait.php
See example below. Call to static::$var fail when this trait is implemented on a parent model and the child is called. <?php trait T { private static $traitVar = "trait"; public function getTraitSelf() { return self::$traitVar; } public function getTraitStatic() { return static::$traitVar; } } class Person { use T; } class Guest extends Person { } echo (new Guest())->getTraitSelf() . PHP_EOL; // Fail echo (new Guest())->getTraitStatic() . PHP_EOL; echo (new Person())->getTraitSelf() . PHP_EOL; // Fail echo (new Person())->getTraitStatic() . PHP_EOL;
1 parent b93988c commit 72d45cb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/AlgoliaEloquentTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ public function getAlgoliaRecordDefault($indexName)
241241

242242
$record = null;
243243

244-
if (method_exists($this, static::$methodGetName)) {
245-
$record = $this->{static::$methodGetName}($indexName);
244+
if (method_exists($this, self::$methodGetName)) {
245+
$record = $this->{self::$methodGetName}($indexName);
246246
} else {
247247
$record = $this->toArray();
248248
}

0 commit comments

Comments
 (0)