https://github.com/y0usefalsaadany/visits-package
Its job is to deal with site views it will give you the number of views of the IP of the person who visited the site, his city, the page he visited and the type of his operating system, and you will also block him temporarily if he makes more than 6 requests per minute on one page
https://github.com/y0usefalsaadany/visits-package
laravel middleware php
Last synced: 6 months ago
JSON representation
Its job is to deal with site views it will give you the number of views of the IP of the person who visited the site, his city, the page he visited and the type of his operating system, and you will also block him temporarily if he makes more than 6 requests per minute on one page
- Host: GitHub
- URL: https://github.com/y0usefalsaadany/visits-package
- Owner: y0usefalsaadany
- Created: 2022-06-28T12:10:40.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-04T12:59:12.000Z (about 4 years ago)
- Last Synced: 2024-07-31T09:50:32.100Z (almost 2 years ago)
- Topics: laravel, middleware, php
- Language: PHP
- Homepage:
- Size: 29.3 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# install package
```
composer require yousefpackage/visits
```
# then goto config folder
in app.php
write this in $routeMiddleware
```
'providers' => [
Yousefpackage\Visits\VisitServiceProvider::class,
Yousefpackage\Visits\RoutePackageServiceProvider::class,
],
```
# then goto kernel.php
write this in $routeMiddleware
```
'visit' => \Yousefpackage\Visits\Http\Middleware\VistsMiddleware::class,
```
# then run this command
```
php artisan migrate
```
# test package
now for test this package goto your browser and write this visits-package
```
http://127.0.0.1:8000/visits-package
```
# using
Now Put this middleware on the route you want to calculate the number of views for.
```
->middleware('throttle:visit', 'visit');
```
like this
```
Route::get('/', function () {
return view('welcome');
})->middleware('throttle:visit', 'visit');
```
If you want to calculate the number of views you have, make a controller and then put this code
```
select('ip')->count(); // To count the number of views
return Visit::all(); // To display the data in the visits table
}
}
>
```
And we find in the table that we have the visitor’s IP, his city, the page he visited and the type of his operating system