diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php new file mode 100644 index 00000000000..ffdc56f9b53 --- /dev/null +++ b/bootstrap/helpers.php @@ -0,0 +1,21 @@ +user(); + + if ($currentUser === null) { + throw new Exception('The current user is not authenticated.'); + } + + if (! $currentUser instanceof User) { + throw new Exception('The currently authenticated user is not an instance of '.User::class); + } + + return $currentUser; +} diff --git a/composer.json b/composer.json index 9c446ae87e7..a00d96fdfab 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" - } + }, + "files": ["bootstrap/helpers.php"] }, "autoload-dev": { "psr-4": {