Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
CreateShortcutCategoryPosition | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
handle | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Listeners\Business; |
4 | |
5 | use App\Events\User\Registered; |
6 | use App\Http\Models\ShortcutCategory; |
7 | use App\Http\Models\ShortcutCategoryPosition; |
8 | |
9 | class CreateShortcutCategoryPosition |
10 | { |
11 | public function handle(Registered $event): void |
12 | { |
13 | $searchArray = [ |
14 | 'user_id' => $event->user->id, |
15 | 'is_default' => true, |
16 | ]; |
17 | $defaultCategory = ShortcutCategory::withoutGlobalScopes()->where($searchArray)->first(); |
18 | |
19 | $data = [ |
20 | 'user_id' => $event->user->id, |
21 | 'positions' => [$defaultCategory->id], |
22 | ]; |
23 | ShortcutCategoryPosition::create($data); |
24 | } |
25 | } |