PHP code example of nexxai / laravel-analytics
1. Go to this page and download the library: Download nexxai/laravel-analytics library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nexxai / laravel-analytics example snippets
protected $routeMiddleware = [
...
'analytics' => \Nexxai\LaravelAnalytics\Http\Middleware\Analytics::class,
...
];
Route::middleware(['analytics'])->group(function () {
Route::get('/', [PagesController::class,'index'])->name('pages.home');
});
$pageViewRepository = app(PageViewRepository::class);
$pageViewsPerDays = $pageViewRepository->getByDateGroupedByDays(Carbon::today()->subDays(28));
$pageViewsPerPaths = $pageViewRepository->getByDateGroupedByPath(Carbon::today()->subDays(28));
return view('admin.dashboard.index',
[
'pageViewsPerDays' => $pageViewsPerDays,
'pageViewsPerPaths' => $pageViewsPerPaths
]);
<page-views-per-days :initial-data="{{json_encode($pageViewsPerDays)}}"/>
<page-views-per-paths :initial-data="{{json_encode($pageViewsPerPaths)}}"/>
bash
php artisan vendor:publish --provider="Nexxai\LaravelAnalytics\LaravelAnalyticsServiceProvider"
bash
php artisan migrate