From e12961891052a31ceec4f1f20c280b42a372c171 Mon Sep 17 00:00:00 2001 From: Gregor Klevze Date: Sun, 8 Feb 2026 17:10:22 +0100 Subject: [PATCH] toolbar fixed --- app/Providers/AppServiceProvider.php | 53 ++++++- composer.json | 1 + composer.lock | 146 +++++++++++++++++- .../views/layouts/nova/toolbar.blade.php | 14 +- 4 files changed, 205 insertions(+), 9 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b65..65898c71 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,9 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; +use Illuminate\Support\Facades\View; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Auth; class AppServiceProvider extends ServiceProvider { @@ -19,6 +22,54 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + // Provide toolbar counts and user info to layout views (port of legacy toolbar logic) + View::composer(['layouts.nova', 'layouts.nova.*'], function ($view) { + $uploadCount = $favCount = $msgCount = $noticeCount = 0; + $avatar = null; + $displayName = null; + + if (Auth::check()) { + $userId = Auth::id(); + try { + $uploadCount = DB::table('artworks')->where('user_id', $userId)->count(); + } catch (\Throwable $e) { + $uploadCount = 0; + } + + try { + // legacy table name fallback handled elsewhere; here we look for user_favorites or favourites + $favCount = DB::table('user_favorites')->where('user_id', $userId)->count(); + } catch (\Throwable $e) { + try { + $favCount = DB::table('favourites')->where('user_id', $userId)->count(); + } catch (\Throwable $e) { + $favCount = 0; + } + } + + try { + $msgCount = DB::table('messages')->where('reciever_id', $userId)->whereNull('read_at')->count(); + } catch (\Throwable $e) { + $msgCount = 0; + } + + try { + $noticeCount = DB::table('notification')->where('user_id', $userId)->where('new', 1)->count(); + } catch (\Throwable $e) { + $noticeCount = 0; + } + + try { + $profile = DB::table('user_profiles')->where('user_id', $userId)->first(); + $avatar = $profile->avatar ?? null; + } catch (\Throwable $e) { + $avatar = null; + } + + $displayName = Auth::user()->name ?: (Auth::user()->username ?? ''); + } + + $view->with(compact('userId','uploadCount', 'favCount', 'msgCount', 'noticeCount', 'avatar', 'displayName')); + }); } } diff --git a/composer.json b/composer.json index c636a00b..da4875cc 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "license": "MIT", "require": { "php": "^8.2", + "intervention/image": "^3.11", "laravel/framework": "^12.0", "laravel/tinker": "^2.10.1" }, diff --git a/composer.lock b/composer.lock index 128eeef4..6165b65d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "77e9cb13ddd5d3584f5743ca484b7d65", + "content-hash": "b8907494f0d247052cb415463bd9f356", "packages": [ { "name": "brick/math", @@ -1052,6 +1052,150 @@ ], "time": "2025-08-22T14:27:06+00:00" }, + { + "name": "intervention/gif", + "version": "4.2.4", + "source": { + "type": "git", + "url": "https://github.com/Intervention/gif.git", + "reference": "c3598a16ebe7690cd55640c44144a9df383ea73c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/gif/zipball/c3598a16ebe7690cd55640c44144a9df383ea73c", + "reference": "c3598a16ebe7690cd55640c44144a9df383ea73c", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", + "slevomat/coding-standard": "~8.0", + "squizlabs/php_codesniffer": "^3.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Intervention\\Gif\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "https://intervention.io/" + } + ], + "description": "Native PHP GIF Encoder/Decoder", + "homepage": "https://github.com/intervention/gif", + "keywords": [ + "animation", + "gd", + "gif", + "image" + ], + "support": { + "issues": "https://github.com/Intervention/gif/issues", + "source": "https://github.com/Intervention/gif/tree/4.2.4" + }, + "funding": [ + { + "url": "https://paypal.me/interventionio", + "type": "custom" + }, + { + "url": "https://github.com/Intervention", + "type": "github" + }, + { + "url": "https://ko-fi.com/interventionphp", + "type": "ko_fi" + } + ], + "time": "2026-01-04T09:27:23+00:00" + }, + { + "name": "intervention/image", + "version": "3.11.6", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "5f6d27d9fd56312c47f347929e7ac15345c605a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/image/zipball/5f6d27d9fd56312c47f347929e7ac15345c605a1", + "reference": "5f6d27d9fd56312c47f347929e7ac15345c605a1", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "intervention/gif": "^4.2", + "php": "^8.1" + }, + "require-dev": { + "mockery/mockery": "^1.6", + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", + "slevomat/coding-standard": "~8.0", + "squizlabs/php_codesniffer": "^3.8" + }, + "suggest": { + "ext-exif": "Recommended to be able to read EXIF data properly." + }, + "type": "library", + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "https://intervention.io" + } + ], + "description": "PHP Image Processing", + "homepage": "https://image.intervention.io", + "keywords": [ + "gd", + "image", + "imagick", + "resize", + "thumbnail", + "watermark" + ], + "support": { + "issues": "https://github.com/Intervention/image/issues", + "source": "https://github.com/Intervention/image/tree/3.11.6" + }, + "funding": [ + { + "url": "https://paypal.me/interventionio", + "type": "custom" + }, + { + "url": "https://github.com/Intervention", + "type": "github" + }, + { + "url": "https://ko-fi.com/interventionphp", + "type": "ko_fi" + } + ], + "time": "2025-12-17T13:38:29+00:00" + }, { "name": "laravel/framework", "version": "v12.49.0", diff --git a/resources/views/layouts/nova/toolbar.blade.php b/resources/views/layouts/nova/toolbar.blade.php index 0d9c539d..8f572d04 100644 --- a/resources/views/layouts/nova/toolbar.blade.php +++ b/resources/views/layouts/nova/toolbar.blade.php @@ -98,7 +98,7 @@ - 37 + {{ $uploadCount ?? 0 }}
-