Conditions | 1 |
Paths | 1 |
Total Lines | 29 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public static function boot(): void |
||
24 | { |
||
25 | App::$Event->on(Main::SEARCH_EVENT_NAME, function ($model) { |
||
26 | /** @var CollectionSearchResults $model */ |
||
27 | $records = User::with('profile') |
||
28 | ->search($model->getQuery()) |
||
29 | ->take($model->getLimit()) |
||
30 | ->get(); |
||
31 | |||
32 | /** @var User[]|Collection $records */ |
||
33 | $records->each(function($item) use ($model) { |
||
34 | /** @var User $item */ |
||
35 | $title = $item->login . '(' . $item->email . ')'; |
||
36 | $text = App::$Translate->get('User', 'Login: %login%, email: %email%, nick: %nick%', [ |
||
37 | 'login' => $item->login, |
||
38 | 'email' => $item->email, |
||
39 | 'nick' => $item->profile->nick ?? 'id' . $item->id |
||
40 | ]); |
||
41 | |||
42 | // initialize abstract response pattern |
||
43 | $res = new AbstractSearchItem(); |
||
44 | $res->setTitle($title); |
||
45 | $res->setSnippet($text); |
||
46 | $res->setDate($item->created_at); |
||
47 | $res->setRelevance((int)$item->relevance); |
||
|
|||
48 | $res->setUrl('user/update', [$item->id]); |
||
49 | $res->setMarker('User'); |
||
50 | |||
51 | $model->add($res); |
||
52 | }); |
||
56 | } |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.