]> BookStack Code Mirror - bookstack/blobdiff - app/Auth/User.php
Add the "Create Shelf" resp. "Create Book" to the home view
[bookstack] / app / Auth / User.php
index 7ad14d9f0c2a495646eb4a4151f958a4a5e2fbf2..bce418a7421fb40ddeb34b0e0dacd192d7048e2a 100644 (file)
@@ -53,13 +53,24 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
      */
     protected $permissions;
 
+    /**
+     * This holds the default user when loaded.
+     * @var null|User
+     */
+    protected static $defaultUser = null;
+
     /**
      * Returns the default public user.
      * @return User
      */
     public static function getDefault()
     {
-        return static::where('system_name', '=', 'public')->first();
+        if (!is_null(static::$defaultUser)) {
+            return static::$defaultUser;
+        }
+        
+        static::$defaultUser = static::where('system_name', '=', 'public')->first();
+        return static::$defaultUser;
     }
 
     /**