fbollon/lara-visitors
最新稳定版本:v1.0.1
Composer 安装命令:
composer require fbollon/lara-visitors
包简介
Laravel package that provides a dashboard and statistics for visits recorded by shetabit/visitor.
README 文档
README
LaraVisitors is a Laravel package that provides a dashboard and statistics for visits recorded by shetabit/visitor.
✨ Features
- Dashboard with visit statistics
- Date filters
- CSV export
- Charts (Chart.js)
- Stats by user, URL, browser, device
- Localization (EN/FR)
✅ Requirements
- Laravel 11 or higher
- PHP 8.2+
📦 Installation
Install package via Composer:
composer require fbollon/lara-visitors
This will also install shetabit/visitor
⚙️ Configuration
Since this package also installs the shetabit/visitor package, we start with its configuration
1. Configure shetabit/visitor
Publish the configuration file:
php artisan vendor:publish --provider="Shetabit\Visitor\Provider\VisitorServiceProvider" --tag="config"
If needed, change the default table name in config/visitor.php:
// Name of the table where visit records should be saved 'table_name' => 'shetabit_visits',
Publish the migrations and run them:
php artisan vendor:publish --provider="Shetabit\Visitor\Provider\VisitorServiceProvider" --tag="migrations" php artisan migrate
Add the middleware to app/Http/Kernel.php to automatically log visits:
protected $middlewareGroups = [ 'web' => [ // other middlewares... \Shetabit\Visitor\Middlewares\LogVisits::class, ], ];
Add the trait to your User model:
use Shetabit\Visitor\Traits\Visitor; class User extends Model { use Visitor; }
2. Configure fbollon/lara-visitors
Publish the configuration file:
php artisan vendor:publish --tag=laravisitors-config
This will create config/laravisitors.php where you can customize:
- provide_assets: Load Bootstrap 5, Chart.js, and Font Awesome (set to
falseif your app already includes them). - layout: Define the layout used by package views.
- If you want to use the minimal layout provided by the package, you must set provide_assets to true.
- access_middleware: Middlewares applied to package routes.
- visits_table: Table name for visits (should match shetabit/visitor).
- user_model: Your User model class.
- user_display_attribute: User attribute to display in dashboard.
Optional: Publish assets (CSS/JS) if you want to customize them:
php artisan vendor:publish --tag=laravisitors-assets
Optional: Publish the layout if you want to override the default:
php artisan vendor:publish --tag=laravisitors-layout
Optional: Publish lang file, if you want to override :
php artisan vendor:publish --tag=laravisitors-translations
🌍 Localization
LaraVisitors supports multiple languages (EN/FR).
To override translations:
php artisan vendor:publish --tag=laravisitors-translations
Files will be published to lang/vendor/laravisitors/{locale}/messages.php.
🔍 Usage
Access the dashboard at:
/laravisitors/dashboard
✅ Example config/laravisitors.php
return [ 'provide_assets' => true, 'layout' => 'laravisitors::layouts.minimal', 'access_middleware' => ['web', 'auth', 'laravisitors.access'], 'visits_table' => env('LARAVISITORS_TABLE', 'shetabit_visits'), 'user_model' => env('LARAVISITORS_USER_MODEL', App\Models\User::class), 'user_display_attribute' => 'name', ];
🛠 Contributing
Feel free to submit issues or pull requests on GitHub.
📄 License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-16
