This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.
You can install the package via composer:
composer require wdev-rs/laravel-analytics
Install the vue-chartjs integration
npm install vue-chartjs@^4.0.0 chart.js
Publish the vendor files by running
php artisan vendor:publish --provider="WdevRs\LaravelAnalytics\LaravelAnalyticsServiceProvider"
Run migration
php artisan migrate
Add alias to middleware in app/Http/Kernel.php
protected $routeMiddleware = [
...
'analytics' => \WdevRs\LaravelAnalytics\Http\Middleware\Analytics::class,
...
];
Add the analytics
middleware to the routes you'd like to track
Route::middleware(['analytics'])->group(function () {
Route::get('/', [PagesController::class,'index'])->name('pages.home');
});
Register the vue components to display analytics
Vue.component('page-views-per-days', require('./vendor/laravel-analytics/components/PageViewsPerDays.vue').default);
Vue.component('page-views-per-paths', require('./vendor/laravel-analytics/components/PageViewsPerPaths.vue').default);
Use the components in your dashboard or where you like :)
Pass the data from controller
$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)}}"/>
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email daniel@wdev.rs instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.