- Add Analytics container: models, tasks, jobs, controllers, routes, services - Add analytics config with section groups (structure, institute, content, services) - Add database tables: analytics_sessions, analytics_hits, analytics_daily_stats - Add frontend: Analytics page, section detail, chart, overview, navigation components - Add consent banner and JS tracking service (sendBeacon + Inertia listener) - Add permission sync for view_analytics, view_any_analytic - Fix trailing slash URL matching in GetNavigationSectionsTask - Fix event propagation on expand arrows in navigation sections - Fix RecordVisitJob to not depend on dropped analytics_geo_cache table - Replace plain text views/visitors with badge-style icons - Group navigation sections by category with separate blocks - Add config-driven non-CMS sections (faculties, divisions, DPO, journals) - Remove Events, TV, Sveden from analytics sections
61 lines
2.0 KiB
PHP
Executable File
61 lines
2.0 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Containers\AppStructure\Tasks\GetCachedNavigationDataTask;
|
|
use App\Containers\AppStructure\Tasks\GenerateBreadcrumbsTask;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Middleware;
|
|
use Tightenco\Ziggy\Ziggy;
|
|
|
|
class HandleInertiaRequests extends Middleware
|
|
{
|
|
protected $rootView = 'app';
|
|
|
|
public function __construct(private readonly GenerateBreadcrumbsTask $generateBreadcrumbsTask){}
|
|
|
|
public function version(Request $request): ?string
|
|
{
|
|
return parent::version($request);
|
|
}
|
|
|
|
public function share(Request $request): array
|
|
{
|
|
if (str_starts_with($request->path(), 'dashboard')) {
|
|
config(['inertia.ssr.enabled' => false]);
|
|
}
|
|
|
|
return [
|
|
...parent::share($request),
|
|
'app' => [
|
|
'env' => app()->environment(),
|
|
],
|
|
'auth' => [
|
|
'user' => $request->user() ? $request->user()->only('id', 'name', 'email', 'created_at') : null,
|
|
'permissions' => $request->user()?->getAllPermissions()->pluck('name')->toArray() ?? [],
|
|
'roles' => $request->user()?->getRoleNames()->toArray() ?? [],
|
|
],
|
|
'ziggy' => function() {
|
|
return array_merge((new Ziggy())->toArray(), [
|
|
'location' => url()->current(),
|
|
]);
|
|
},
|
|
'navigation' => app(GetCachedNavigationDataTask::class)->run(),
|
|
'breadcrumbs' => $this->generateBreadcrumbsTask->run(),
|
|
'urlPrev' => function () {
|
|
if (url()->previous() !== url()->current()) {
|
|
return url()->previous();
|
|
}
|
|
return 'empty';
|
|
},
|
|
'flash' => function () use ($request) {
|
|
return [
|
|
'success' => $request->session()->get('success'),
|
|
'error' => $request->session()->get('error'),
|
|
'extracted_text' => $request->session()->get('extracted_text'),
|
|
];
|
|
},
|
|
];
|
|
}
|
|
}
|