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