Clean up bloated logic in events for Tag model
MODIFY
app/Events/TagCreated.php
app/Events/TagCreated.php
@@ -17,15 +17,9 @@ class TagCreated {
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(Tag $tag) {
- $userId = null;
-
- if (Auth::check()) {
- $userId = Auth::user()->id;
- }
-
Notification::create([
'space_id' => $tag->space_id,
- 'user_id' => $userId,
+ 'user_id' => Auth::user()->id,
'entity_id' => $tag->id,
'entity_type' => 'tag',
'action' => 'tag.created'

MODIFY
app/Events/TagDeleted.php
app/Events/TagDeleted.php
@@ -17,15 +17,9 @@ class TagDeleted {
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(Tag $tag) {
- $userId = null;
-
- if (Auth::check()) {
- $userId = Auth::user()->id;
- }
-
Notification::create([
'space_id' => $tag->space_id,
- 'user_id' => $userId,
+ 'user_id' => Auth::user()->id,
'entity_id' => $tag->id,
'entity_type' => 'tag',
'action' => 'tag.deleted'

Clean up bloated logic in events for Tag model