In my Laravel 5.7 application I want to use elasticsearch and I found this https://michaelstivala.com/learning-elasticsearch-with-laravel/ article. Firstly I wanted to import all data from a table I want to use with elasticsearch 1) I created a wrapper file app/Elastic.php, with content from githubusercontent. Is this proper dir for this file?
2) In my model app/Vote.php I added function
public static function bulkVotesToElastic() {
$elastic = app(App\Elastic\Elastic::class);
Vote::chunk(100, function ($Votes) use ($elastic) {
foreach ($Votes as $Vote) {
$elastic->index([
'index' => 'select_vote',
'type' => 'vote',
'id' => $Vote->id,
'body' => $Vote->toArray()
]);
}
});
}
As I have seeder for filling of init data. But calling this method I got error:
Class App\App\Elastic\Elastic does not exist
Why error and how to fix it?
actually this line
$elastic = app(App\Elastic\Elastic::class);
is behind my laravel expierence...
Thanks!