-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.php
More file actions
60 lines (52 loc) · 1.42 KB
/
User.php
File metadata and controls
60 lines (52 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace App\Models;
use Laravel\Scout\Searchable;
class User
{
use Searchable;
public static function searchableAs(): string
{
return 'users';
}
public static function indexableAs(): string
{
// inspiration for an initial migration hack, remove when aliases are in use
if (env('APP_ENV') !== 'local' && env('TYPESENSE_VERSION_SUFFIX') === null) {
return self::searchableAs();
}
// @phpstan-ignore larastan.noEnvCallsOutsideOfConfig
return self::searchableAs() . '_' . env('TYPESENSE_VERSION_SUFFIX', 'default');
}
public static function getCollectionSchema(): array
{
return [
'name' => self::indexableAs(),
'fields' => [
[
'name' => 'id',
'type' => 'string',
],
[
'name' => 'name',
'type' => 'string',
],
[
'name' => 'email',
'type' => 'string',
],
[
'name' => 'created_at',
'type' => 'int64',
],
],
'default_sorting_field' => 'created_at',
];
}
public static function typesenseQueryBy(): array
{
return [
'name',
'email',
];
}
}