Elasticquent icon indicating copy to clipboard operation
Elasticquent copied to clipboard

[Proposal] Keep ElasticquentResultCollection@__construct has the same signature as \Illuminate\Database\Eloquent\Collection

Open chuangbo opened this issue 9 years ago • 5 comments

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.

chuangbo avatar Apr 06 '16 11:04 chuangbo

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.

onbjerg avatar Apr 06 '16 14:04 onbjerg

Yeah, can you please make sure that you are using dev-master, and try again @chuangbo ?

timgws avatar Apr 07 '16 02:04 timgws

@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

chuangbo avatar Apr 07 '16 03:04 chuangbo

What version of Elasticsearch are you using?

timgws avatar Apr 07 '16 11:04 timgws

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?

chuangbo avatar Apr 07 '16 12:04 chuangbo