Elasticquent
Elasticquent copied to clipboard
[Proposal] Keep ElasticquentResultCollection@__construct has the same signature as \Illuminate\Database\Eloquent\Collection
As previous discussion #49, by implement this may fix map, filter, etc. Because Collection use new static in many places.
ElasticquentResultCollection@__construct is going to accept $items only, and then set elasticsearch results by ElasticquentResultCollection@setElasticsearchResults.
This is what we're doing now. The second parameter of the constructor in ElasticquentResultCollection is optional, and thus not used when map etc is called and a new collection is returned.
Yeah, can you please make sure that you are using dev-master, and try again @chuangbo ?
@timgws Yes I'm using dev-master.
laravel/framework version: v5.2.29
\App\Product::search('test')->map(function() {})
PHP error: Undefined index: took in /app/vendor/elasticquent/elasticquent/src/ElasticquentResultCollection.php on line 24
What version of Elasticsearch are you using?
Elasticsearch: 2.2.1 elasticsearch-php: 2.0.3
Just found this fork has implemented the similar proposal.
Do you mind me to semi-cherry-pick to here?