1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CSlant\Blog\Core\Models\Traits; |
4
|
|
|
|
5
|
|
|
use CSlant\Blog\Core\Models\User; |
6
|
|
|
use CSlant\Blog\ElasticScout\Modules\Traits\SearchableAs; |
|
|
|
|
7
|
|
|
use Illuminate\Support\Facades\Log; |
8
|
|
|
use Laravel\Scout\Searchable; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Trait UserTrait |
12
|
|
|
* @package CSlant\Blog\Core\Models\Traits |
13
|
|
|
* @mixin SearchableAs |
14
|
|
|
* |
15
|
|
|
* @method string userSearchableAs() see \CSlant\Blog\ElasticScout\Modules\Traits\SearchableAs::userSearchableAs() |
16
|
|
|
*/ |
17
|
|
|
trait UserTrait |
18
|
|
|
{ |
19
|
|
|
use Searchable; |
20
|
|
|
use SearchableAs; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Elastisearch config |
24
|
|
|
* Get the index name for the model. |
25
|
|
|
* |
26
|
|
|
* @return string |
27
|
|
|
*/ |
28
|
|
|
public function searchableAs(): string |
29
|
|
|
{ |
30
|
|
|
return $this->userSearchableAs(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Elastisearch config |
35
|
|
|
* Get the indexable data array for the model. |
36
|
|
|
* |
37
|
|
|
* @return array |
38
|
|
|
*/ |
39
|
|
|
public function toSearchableArray(): array |
40
|
|
|
{ |
41
|
|
|
Log::info("UserTrait::toSearchableArray(), Es User: " . $this->getKey()); |
42
|
|
|
|
43
|
|
|
/** @var User $this */ |
44
|
|
|
return [ |
45
|
|
|
'id' => $this->id, |
46
|
|
|
'email' => $this->email, |
47
|
|
|
'email_lowercase' => strtolower($this->email), |
48
|
|
|
'created_at' => $this->created_at, |
49
|
|
|
'updated_at' => $this->updated_at, |
50
|
|
|
'first_name' => $this->first_name ?? null, |
51
|
|
|
'last_name' => $this->last_name ?? null, |
52
|
|
|
'username' => $this->username, |
53
|
|
|
'permissions' => $this->permissions ?? null, |
54
|
|
|
'avatar' => $this->avatar?->name ?? null, |
55
|
|
|
'avatar_url' => $this->avatar?->url ?? null, |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Elastisearch config |
61
|
|
|
* Determine if the model should be searchable. |
62
|
|
|
* |
63
|
|
|
* @return bool |
64
|
|
|
*/ |
65
|
|
|
public function shouldBeSearchable(): bool |
66
|
|
|
{ |
67
|
|
|
return !$this->wasChanged(); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths