Update events so tests can run without needing Auth facade
MODIFY
app/Events/RecurringCreated.php
app/Events/RecurringCreated.php
@@ -17,9 +17,15 @@ class RecurringCreated {
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(Recurring $recurring) {
+ $userId = null;
+
+ if (Auth::check()) {
+ $userId = Auth::user()->id;
+ }
+
Notification::create([
'space_id' => $recurring->space_id,
- 'user_id' => Auth::user()->id,
+ 'user_id' => $userId,
'entity_id' => $recurring->id,
'entity_type' => 'recurring',
'action' => 'recurring.created'

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

MODIFY
app/Events/TagCreated.php
app/Events/TagCreated.php
@@ -17,9 +17,15 @@ 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' => Auth::user()->id,
+ 'user_id' => $userId,
'entity_id' => $tag->id,
'entity_type' => 'tag',
'action' => 'tag.created'

MODIFY
app/Events/TagDeleted.php
app/Events/TagDeleted.php
@@ -17,9 +17,15 @@ 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' => Auth::user()->id,
+ 'user_id' => $userId,
'entity_id' => $tag->id,
'entity_type' => 'tag',
'action' => 'tag.deleted'

MODIFY
app/Providers/AppServiceProvider.php
app/Providers/AppServiceProvider.php
@@ -11,7 +11,7 @@ class AppServiceProvider extends ServiceProvider {
view()->composer('*', function($view) {
$view->with([
'userName' => Auth::check() ? Auth::user()->name : null,
- 'currency' => Auth::check() ? session('space')->currency->symbol : null
+ 'currency' => Auth::check() ? session('space') ? session('space')->currency->symbol : '-' : null
]);
});
}

MODIFY
database/factories/ModelFactory.php
database/factories/ModelFactory.php
@@ -10,7 +10,6 @@ use App\Recurring;
$factory->define(User::class, function (Generator $faker) {
return [
- 'currency_id' => $faker->numberBetween(1, 3),
'name' => $faker->firstName,
'email' => $faker->unique()->safeEmail,
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
@@ -20,6 +19,7 @@ $factory->define(User::class, function (Generator $faker) {
$factory->define(Space::class, function (Generator $faker) {
return [
+ 'currency_id' => $faker->numberBetween(1, 3),
'name' => $faker->firstName . '\'s Space'
];
});

Update events so tests can run without needing Auth facade