<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
funnydevjsc / google-analytic-laravel-integrate example snippets
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
// Other kernel properties...
/**
* The application's route middleware groups.
*
* @var array
*/
protected $routeMiddleware = [
// Other middlewares...
'google-analytic' => 'App\Http\Middleware\GoogleAnalyticMiddleware',
];
}
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
...
/**
* Bootstrap any application services.
*/
public function boot(): void
{
...
View::addNamespace('google-analytics', base_path('resources/views/vendor/google-analytics'));
View::share('userData', Session::get('userData') ?? '');
}
}