From 98dc190dc58d5b9609b0dfac0b74c317ef1007d1 Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Tue, 11 Mar 2025 11:29:21 +0100 Subject: [PATCH] V0.1.1 User.php: - User.php: +findRole() +hasRole() +isAdmin() --- CHANGELOG.md | 6 +++++- app/Models/User.php | 34 ++++++++++++++++++++++++++++++++++ composer.lock | 16 ++++++++-------- lang/de_DE.json | 3 +++ 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58d6198..d20d140 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,5 @@ -# Change log of zentrum +# Änderungen an zentrum + +# V0.1.1 +- User.php: +findRole() +hasRole() +isAdmin() + diff --git a/app/Models/User.php b/app/Models/User.php index 20ab419..1456394 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -48,4 +48,38 @@ class User extends Authenticatable ]; } + /** + * 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; + } } diff --git a/composer.lock b/composer.lock index eb47940..02b382f 100644 --- a/composer.lock +++ b/composer.lock @@ -6233,16 +6233,16 @@ }, { "name": "laravel/pint", - "version": "v1.21.0", + "version": "v1.21.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "531fa0871fbde719c51b12afa3a443b8f4e4b425" + "reference": "c44bffbb2334e90fba560933c45948fa4a3f3e86" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/531fa0871fbde719c51b12afa3a443b8f4e4b425", - "reference": "531fa0871fbde719c51b12afa3a443b8f4e4b425", + "url": "https://api.github.com/repos/laravel/pint/zipball/c44bffbb2334e90fba560933c45948fa4a3f3e86", + "reference": "c44bffbb2334e90fba560933c45948fa4a3f3e86", "shasum": "" }, "require": { @@ -6253,9 +6253,9 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.68.5", - "illuminate/view": "^11.42.0", - "larastan/larastan": "^3.0.4", + "friendsofphp/php-cs-fixer": "^3.70.2", + "illuminate/view": "^11.44.1", + "larastan/larastan": "^3.1.0", "laravel-zero/framework": "^11.36.1", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^2.3", @@ -6295,7 +6295,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2025-02-18T03:18:57+00:00" + "time": "2025-03-11T03:22:21+00:00" }, { "name": "laravel/sail", diff --git a/lang/de_DE.json b/lang/de_DE.json index 846eb16..0f773dd 100644 --- a/lang/de_DE.json +++ b/lang/de_DE.json @@ -17,6 +17,7 @@ "All": "Alle", "Amount": "Betrag", "Analysis": "Analyse", + "Article": "Artikel", "Assign Roles": "Rollen zuordnen", "Back": "Zur\u00fcck", "Body": "Info", @@ -91,6 +92,7 @@ "Duration": "Dauer", "Duration (minutes)": "Dauer (Minuten)", "Email": "Email", + "Email has been sent if the email address is known.": "Email wurde gesendet, wenn die Emailadresse bekannt ist.", "Email\/Phone": "Email\/Telefon", "English (Britisch)": "Englisch (GB)", "Exchange of a File": "Austausch einer Datei", @@ -103,6 +105,7 @@ "Files": "Dateien", "Filtered": "Gefiltert", "Firstname": "Vorname", + "Forgotten Password?": "Passwort vergessen?", "French (France)": "Franz\u00f6sisch (Frankreich)", "Fri": "Fr", "From": "Von", -- 2.39.5