+# V 0.1.4 Layout
+
+- User: new: isGuest()
+- Layout: non auth mode: no "administration", "login" button
+- web.php: "/": depending in auth mode
+
# V 0.1.3 i18n
# V 0.1.2 view/change
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
+use Illuminate\Support\Facades\Auth;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
];
}
+ /**
+ * Returns the role of the user.
+ *
+ * @return Role the role of the user
+ */
+ protected function findRole()
+ {
+ if ($this->role == null){
+ $this->role = Role::find($this->role_id);
+ }
+ return $this->role;
+ }
+ /**
+ * Tests whether the user has a role with a priority less than or equal to the given priority. The lower the priority, the more powerful the role.
+ * @param int $priority the priority to test against
+ * @return bool True if the user has a role with a priority less than or equal to the given priority, False otherwise
+ */
+ public function hasRole(int $priority): bool
+ {
+ $role = $this->findRole();
+ $rc = $this->role->priority <= $priority;
+ return $rc;
+ }
+ /**
+ * Tests whether the user is an admin.
+
+ * @return bool True if the user is an admin, False otherwise
+ */
+ public function isAdmin(): bool
+ {
+ $this->findRole();
+ $rc = $this->role->priority <= 19;
+ return $rc;
+ }
+ /**
+ * Tests whether the user is a guest (not logged in).
+
+ * @return bool True if the user is a guest
+ */
+ public static function isGuest(): bool
+ {
+ $rc = ! Auth::check();
+ return $rc;
+ }
}
<div id="navbarTop" class="collapse navbar-collapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
- <a class="nav-link" href="/page-showmenu/main">Start</a>
+ @auth
+ <a class="nav-link" href="/page-startpage">Start</a>
+ @else
+ <a class="nav-link" href="/page-startpublic">Start</a>
+ @endauth
</li>
+ @auth
<li class="nav-item active">
<a class="nav-link" href="/menuitem-menu_main">Verwaltung</a>
</li>
+ @endauth
<li>
- <a class="nav-link" href="/public/doc/Impressum.pdf" target="_blank">{{ __('Imprint') }}</a>
+ <a class="nav-link" href="/page-showbyname/imprint/1141">{{ __('Imprint') }}</a>
</li>
<li>
- <a class="nav-link" href="/public/doc/Datenschutz.pdf" target="_blank">{{ __('Privacy') }}</a>
+ <a class="nav-link" href="/page-showbyname/privacy/1141">{{ __('Privacy') }}</a>
</li>
</ul>
<ul id="lkn-navbar-right" class="navbar-nav mr-auto lkn-logout">
<li class="nav-item border rounded-3">
<a class="nav-link" href="/user-edit-current">{{ session('userName') }}</a>
</li>
- @endauth
<li class="nav-item border rounded-3">
<a class="nav-link" href="/user-logout">{{ __('Logout') }}</a>
</li>
+ @else
+ <li class="nav-item border rounded-3">
+ <a class="nav-link" href="/user-login">{{ __('Login') }}</a>
+ </li>
+ @endauth
</ul>
</div>
</nav>
use App\Http\Controllers\AccountController;
use App\Http\Controllers\TransactionController;
-Route::get('/', function () {
- return redirect('/menuitem-menu_main');
-});
+if (User::isGuest()) {
+ Route::get('/', function () {
+ return redirect('/page-startpublic');
+ });
+
+} else {
+ Route::get('/', function () {
+ return redirect('/page-start');
+ });
+}
RoleController::routes();
SPropertyController::routes();
UserController::routes();