Skip to content

Commit 0b4ddba

Browse files
Added "searchable()" and Elasticsearch authentication. (ActiveLearningStudio#54)
1 parent 637ff60 commit 0b4ddba

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ GAPI_CLIENT_ID=
5959
CURRIKI_TSUGI_HOST=
6060

6161
ELASTIC_HOST=
62+
ELASTIC_USER=
63+
ELASTIC_PASS=
6264
ELASTIC_MIGRATIONS_DIRECTORY=elastic/migrations
6365
SCOUT_DRIVER=elastic
6466

app/Repositories/BaseRepository.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ public function create(array $attributes)
5353
*/
5454
public function update(array $attributes, $id)
5555
{
56-
return $this->model->where('id', $id)->update($attributes);
56+
$is_updated = $this->model->where('id', $id)->update($attributes);
57+
58+
if ($is_updated) {
59+
$this->model->where('id', $id)->searchable();
60+
}
61+
62+
return $is_updated;
5763
}
5864

5965
/**

config/elastic.client.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
return [
44
'hosts' => [
5-
env('ELASTIC_HOST', 'localhost:9200'),
5+
[
6+
'host' => env('ELASTIC_HOST', 'localhost:9200'),
7+
'user' => env('ELASTIC_USER', 'user'),
8+
'pass' => env('ELASTIC_PASS', 'pass')
9+
]
610
]
711
];

0 commit comments

Comments
 (0)