composer require oskoala/statistics -vvv
//统计接口
Route::post("statistics", \OsKoala\Statistics\Http\Controllers\StatisticsController::class . '@api');
//需要统计功能的页面
Route::get("/", function () {
return view("index");
});
- 修改 app\Http\Middleware\VerifyCsrfToken.php
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'statistics', //添加这一行
];
}
<h2>index 访问已统计</h2>
<script src="/vendor/dcat-admin-extensions/oskoala/statistics/js/statistics.js"></script>