Install views plugin

This commit is contained in:
Daniel_I_Am 2021-09-04 10:35:20 +02:00
parent a8f67c33f2
commit aaa483289a
4 changed files with 300 additions and 1 deletions

View File

@ -6,6 +6,7 @@
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"cyrildewit/eloquent-viewable": "^6.0",
"doctrine/dbal": "^3.1",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",

131
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2e27ad4aeb64c5f5afd5be0288a4a9e2",
"content-hash": "5ceb5b6e26fc35fd4fd26e6d152d3b11",
"packages": [
{
"name": "asm89/stack-cors",
@ -195,6 +195,83 @@
],
"time": "2021-08-17T13:49:14+00:00"
},
{
"name": "cyrildewit/eloquent-viewable",
"version": "v6.0.2",
"source": {
"type": "git",
"url": "https://github.com/cyrildewit/eloquent-viewable.git",
"reference": "699294489e397c18a59ff9fafadde8154be85c02"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cyrildewit/eloquent-viewable/zipball/699294489e397c18a59ff9fafadde8154be85c02",
"reference": "699294489e397c18a59ff9fafadde8154be85c02",
"shasum": ""
},
"require": {
"illuminate/cache": "^6.0|^7.0|^8.0",
"illuminate/contracts": "^6.0|^7.0|^8.0",
"illuminate/cookie": "^6.0|^7.0|^8.0",
"illuminate/database": "^6.0|^7.0|^8.0",
"illuminate/http": "^6.0|^7.0|^8.0",
"illuminate/support": "^6.0|^7.0|^8.0",
"jaybizzle/crawler-detect": "^1.0",
"nesbot/carbon": "^2.0",
"php": "^7.4|^8.0"
},
"require-dev": {
"illuminate/config": "^6.0|^7.0|^8.0",
"mockery/mockery": "^1.2.4",
"orchestra/testbench": "^4.9.1|^5.9.1|^6.6.1",
"phpunit/phpunit": "^9.3.3"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"CyrildeWit\\EloquentViewable\\EloquentViewableServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"CyrildeWit\\EloquentViewable\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Cyril de Wit",
"email": "info@cyrildewit.nl",
"homepage": "http://cyrildewit.nl",
"role": "Developer"
}
],
"description": "Laravel package that allows you to associate views with Eloquent models",
"homepage": "https://github.com/cyrildewit/eloquent-viewable",
"keywords": [
"counter",
"eloquent",
"hits",
"laravel",
"viewable",
"views",
"visitable",
"visits"
],
"support": {
"issues": "https://github.com/cyrildewit/eloquent-viewable/issues",
"source": "https://github.com/cyrildewit/eloquent-viewable/tree/v6.0.2"
},
"time": "2021-01-02T15:47:17+00:00"
},
{
"name": "dflydev/dot-access-data",
"version": "v3.0.1",
@ -1295,6 +1372,58 @@
},
"time": "2021-06-30T20:03:07+00:00"
},
{
"name": "jaybizzle/crawler-detect",
"version": "v1.2.106",
"source": {
"type": "git",
"url": "https://github.com/JayBizzle/Crawler-Detect.git",
"reference": "78bf6792cbf9c569dc0bf2465481978fd2ed0de9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/78bf6792cbf9c569dc0bf2465481978fd2ed0de9",
"reference": "78bf6792cbf9c569dc0bf2465481978fd2ed0de9",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.5|^6.5|^9.4"
},
"type": "library",
"autoload": {
"psr-4": {
"Jaybizzle\\CrawlerDetect\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Beech",
"email": "m@rkbee.ch",
"role": "Developer"
}
],
"description": "CrawlerDetect is a PHP class for detecting bots/crawlers/spiders via the user agent",
"homepage": "https://github.com/JayBizzle/Crawler-Detect/",
"keywords": [
"crawler",
"crawler detect",
"crawler detector",
"crawlerdetect",
"php crawler detect"
],
"support": {
"issues": "https://github.com/JayBizzle/Crawler-Detect/issues",
"source": "https://github.com/JayBizzle/Crawler-Detect/tree/v1.2.106"
},
"time": "2021-05-24T20:30:32+00:00"
},
{
"name": "laravel/framework",
"version": "v8.58.0",

View File

@ -0,0 +1,107 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Eloquent Models
|--------------------------------------------------------------------------
*/
'models' => [
/*
* Here you can configure the default `View` model.
*/
'view' => [
'table_name' => 'views',
'connection' => env('DB_CONNECTION', 'mysql'),
],
],
/*
|--------------------------------------------------------------------------
| Cache Configuration
|--------------------------------------------------------------------------
*/
'cache' => [
/*
* Everthing will be stored under the following key.
*/
'key' => 'cyrildewit.eloquent-viewable.cache',
/*
* Here you may define the cache store that should be used.
*/
'store' => env('CACHE_DRIVER', 'file'),
],
/*
|--------------------------------------------------------------------------
| Cooldown Configuration
|--------------------------------------------------------------------------
*/
'cooldown' => [
/*
* Everthing will be stored under the following key in the session.
*/
'key' => 'cyrildewit.eloquent-viewable.cooldowns',
],
/*
|--------------------------------------------------------------------------
| Ignore Bots
|--------------------------------------------------------------------------
|
| If you want to ignore bots, you can specify that here. The default
| service that determines if a visitor is a crawler is a package
| by JayBizzle called CrawlerDetect.
|
*/
'ignore_bots' => true,
/*
|--------------------------------------------------------------------------
| Do Not Track Header
|--------------------------------------------------------------------------
|
| If you want to honor the DNT header, you can specify that here. We won't
| record views from visitors with the Do Not Track header.
|
*/
'honor_dnt' => true,
/*
|--------------------------------------------------------------------------
| Cookies
|--------------------------------------------------------------------------
|
| This package binds visitors to views using a cookie. If you want to
| give this cookie a custom name, you can specify that here.
|
*/
'visitor_cookie_key' => 'eloquent_viewable',
/*
|--------------------------------------------------------------------------
| Ignore IP Addresses
|--------------------------------------------------------------------------
|
| Ignore views of the following IP addresses.
|
*/
'ignored_ip_addresses' => [
// '127.0.0.1',
],
];

View File

@ -0,0 +1,62 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateViewsTable extends Migration
{
/**
* The database schema.
*
* @var \Illuminate\Support\Facades\Schema
*/
protected $schema;
/**
* The table name.
*
* @var string
*/
protected $table;
/**
* Create a new migration instance.
*
* @return void
*/
public function __construct()
{
$this->schema = Schema::connection(
config('eloquent-viewable.models.view.connection')
);
$this->table = config('eloquent-viewable.models.view.table_name');
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$this->schema->create($this->table, function (Blueprint $table) {
$table->bigIncrements('id');
$table->morphs('viewable');
$table->text('visitor')->nullable();
$table->string('collection')->nullable();
$table->timestamp('viewed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$this->schema->dropIfExists($this->table);
}
}