Guys, I welcome everyone. In general, I faced such a question.
Simplify non-essential nuances. There is a statistic_visit table in the database. Approximately with this structure: id|visit|date That is, roughly speaking, each time you refresh the page, visit should be incremented where the date is today.
Probing the Internet and documentation, I thought that it would be more correct to do it through the Provider :
class StatisticVisitProvider extends ServiceProvider { public function boot(Request $request) { $toDay = date("Ymd"); StatisticVisit::where('day', $toDay)->increment('view', 1); } public function register() { } } Everything works out, but there is one problem. In the database, with each update, it does not add to 1, but to a larger number, for example, 3, 80 . Apparently depending on what page I open.
And, accordingly, the conclusion suggests itself that the provider works more than once. That is, with each ajax request, or the loading of a widget, it executes an increment.
I ask you to suggest how to implement this correctly, if I am on the right path, if not then send.
Thank you very much in advance.
$routeMiddlewareand after the routes I needed, I assigned the created mediator. - Arendach