Merge branch 'develop'

This commit is contained in:
Refringe 2024-06-19 13:23:44 -04:00
commit 9d0303f787
Signed by: Refringe
SSH Key Fingerprint: SHA256:t865XsQpfTeqPRBMN2G6+N8wlDjkgUCZF3WGW6O9N/k
10 changed files with 55 additions and 42 deletions

View File

@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Str;
use Laravel\Fortify\TwoFactorAuthenticatable; use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto; use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Sanctum\HasApiTokens; use Laravel\Sanctum\HasApiTokens;
@ -71,6 +72,11 @@ class User extends Authenticatable implements MustVerifyEmail
return $this->belongsTo(UserRole::class, 'user_role_id'); return $this->belongsTo(UserRole::class, 'user_role_id');
} }
public function isAdmin(): bool
{
return Str::lower($this->role->name) === 'administrator';
}
protected function casts(): array protected function casts(): array
{ {
return [ return [

View File

@ -2,6 +2,8 @@
namespace App\Providers; namespace App\Providers;
use App\Models\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
@ -19,6 +21,9 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function boot(): void public function boot(): void
{ {
// // This gate determines who can access the Pulse dashboard.
Gate::define('viewPulse', function (User $user) {
return $user->isAdmin();
});
} }
} }

View File

@ -3,7 +3,6 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use Laravel\Horizon\Horizon;
use Laravel\Horizon\HorizonApplicationServiceProvider; use Laravel\Horizon\HorizonApplicationServiceProvider;
class HorizonServiceProvider extends HorizonApplicationServiceProvider class HorizonServiceProvider extends HorizonApplicationServiceProvider
@ -28,9 +27,7 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
protected function gate(): void protected function gate(): void
{ {
Gate::define('viewHorizon', function ($user) { Gate::define('viewHorizon', function ($user) {
return in_array($user->email, [ return $user->isAdmin();
//
]);
}); });
} }
} }

View File

@ -20,6 +20,16 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
Nova::withBreadcrumbs(); Nova::withBreadcrumbs();
} }
/**
* Get the tools that should be listed in the Nova sidebar.
*
* @return array
*/
public function tools()
{
return [];
}
/** /**
* Register the Nova routes. * Register the Nova routes.
* *
@ -33,6 +43,16 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
->register(); ->register();
} }
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/** /**
* Register the Nova gate. * Register the Nova gate.
* *
@ -43,9 +63,7 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
protected function gate() protected function gate()
{ {
Gate::define('viewNova', function ($user) { Gate::define('viewNova', function ($user) {
return in_array($user->email, [ return $user->isAdmin();
//
]);
}); });
} }
@ -60,24 +78,4 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
new \App\Nova\Dashboards\Main, new \App\Nova\Dashboards\Main,
]; ];
} }
/**
* Get the tools that should be listed in the Nova sidebar.
*
* @return array
*/
public function tools()
{
return [];
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
} }

View File

@ -1,12 +1,9 @@
{ {
"name": "laravel/laravel", "name": "sp-tarkov/forge",
"type": "project", "type": "project",
"description": "The skeleton application for the Laravel framework.", "description": "A Laravel-based web application that provides a platform for the Single Player Tarkov community to share and discover user-generated content, such as mods, guides, and other tools.",
"keywords": [ "keywords": [],
"laravel", "license": "MPL-2.0",
"framework"
],
"license": "MIT",
"require": { "require": {
"php": "^8.3", "php": "^8.3",
"ext-curl": "*", "ext-curl": "*",

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{ {
"name": "html", "name": "forge",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@ -5,9 +5,15 @@ import.meta.glob(["../video/**"]);
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
const themeToggleIcon = { const themeToggleIcon = {
dark: document.getElementById("theme-toggle-dark-icon"), dark: document.getElementById("theme-toggle-dark-icon"),
light: document.getElementById("theme-toggle-light-icon"), light: document.getElementById("theme-toggle-light-icon")
}; };
// Make sure the theme toggle icons are available.
if (themeToggleIcon.dark === null || themeToggleIcon.light === null) {
console.log("Theme toggle icons not found.");
return;
}
// Function to update the visibility of the theme icons based on the theme // Function to update the visibility of the theme icons based on the theme
function updateIconVisibility(theme) { function updateIconVisibility(theme) {
if (theme === "dark") { if (theme === "dark") {

View File

@ -1,4 +1,7 @@
import { Livewire } from "../../vendor/livewire/livewire/dist/livewire.esm";
import axios from "axios"; import axios from "axios";
Livewire.start();
window.axios = axios; window.axios = axios;
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest"; window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";

View File

@ -56,6 +56,6 @@
@livewire('global-search') @livewire('global-search')
@stack('modals') @stack('modals')
@livewireScripts @livewireScriptConfig
</body> </body>
</html> </html>

View File

@ -11,6 +11,8 @@
<link href="//fonts.bunny.net" rel="preconnect"> <link href="//fonts.bunny.net" rel="preconnect">
<link href="//fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet"> <link href="//fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet">
<link href="{{ config('app.asset_url') }}" rel="dns-prefetch">
<script> <script>
// Immediately set the theme to prevent a flash of the default theme when another is set. // Immediately set the theme to prevent a flash of the default theme when another is set.
// Must be located inline, in the head, and before any CSS is loaded. // Must be located inline, in the head, and before any CSS is loaded.
@ -33,7 +35,6 @@
{{ $slot }} {{ $slot }}
</div> </div>
@livewireScripts @livewireScriptConfig
</body> </body>
</html> </html>