Skip to content

Commit

Permalink
Merge pull request #22 from DenisVinokurov/master
Browse files Browse the repository at this point in the history
Support scout 9.*
  • Loading branch information
eigan authored May 16, 2022
2 parents c537f72 + 7612c15 commit 1b00824
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"laravel/scout": "1.*|2.*|3.*|4.*|5.*|6.*|7.*|8.*"
"laravel/scout": "1.*|2.*|3.*|4.*|5.*|6.*|7.*|8.*|9.*"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LaravelDoctrine\Scout\Console;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use Illuminate\Console\Command;
use Illuminate\Contracts\Events\Dispatcher;
use Laravel\Scout\EngineManager;
Expand Down
47 changes: 46 additions & 1 deletion src/Indexable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ trait Indexable
*/
protected $searchableAs;

/**
* @var array
*/
protected $scoutMetadata = [];

/**
* Get primary key value
* @return int
*/
public function getKey()
{
return $this->id;
return $this->{$this->getKeyName()};
}

/**
Expand Down Expand Up @@ -57,4 +62,44 @@ public function setClassMetaData(ClassMetadata $classMetadata)
{
$this->classMetaData = $classMetadata;
}

/**
* @return string
*/
public function getKeyName()
{
return 'id';
}

/**
* @return int
*/
public function getScoutKey()
{
return $this->getKey();
}

/**
* Get all Scout related metadata.
*
* @return array
*/
public function scoutMetadata()
{
return $this->scoutMetadata;
}

/**
* Set a Scout related metadata.
*
* @param string $key
* @param mixed $value
* @return Indexable
*/
public function withScoutMetadata($key, $value)
{
$this->scoutMetadata[$key] = $value;

return $this;
}
}

0 comments on commit 1b00824

Please sign in to comment.