From ef134fbeb270143a9b112a8f6e61ef901358feab Mon Sep 17 00:00:00 2001 From: Remx Date: Tue, 11 Apr 2023 18:30:24 +0800 Subject: [PATCH 1/2] update 'eloquent' to \Awssat\Visits\DataEngines\EloquentEngine::class --- docs/3_installation.md | 4 ++-- docs/4_quick-start.md | 2 +- src/Commands/CleanCommand.php | 3 ++- src/config/visits.php | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/3_installation.md b/docs/3_installation.md index 00a87ed..128da7b 100644 --- a/docs/3_installation.md +++ b/docs/3_installation.md @@ -63,8 +63,8 @@ Laravel Visits can be configured to act the way you like, `config/visits.php` is 'engine' => \Awssat\Visits\DataEngines\RedisEngine::class, ``` -Suported data engines are `\Awssat\Visits\DataEngines\RedisEngine::class`, and `eloquent` currently. -If you use ` \Awssat\Visits\DataEngines\EloquentEngine::class` then data will be stored in the default database (MySQL, SQLite or the one you are using) +Suported data engines are `\Awssat\Visits\DataEngines\RedisEngine::class`, and `\Awssat\Visits\DataEngines\EloquentEngine::class` currently. +If you use `\Awssat\Visits\DataEngines\EloquentEngine::class` then data will be stored in the default database (MySQL, SQLite or the one you are using) #### connection diff --git a/docs/4_quick-start.md b/docs/4_quick-start.md index 23f914d..2bd708f 100644 --- a/docs/4_quick-start.md +++ b/docs/4_quick-start.md @@ -50,7 +50,7 @@ $post->vzt()->count(); ## Relationship with models (only for Eloquent engine) -If you are using visits with eloquent as engine (from config/visits.php; engine => 'eloquent') then you can add a relationship method to your models. +If you are using visits with eloquent as engine (from config/visits.php; engine => \Awssat\Visits\DataEngines\EloquentEngine::class) then you can add a relationship method to your models. ```php class Post extends Model diff --git a/src/Commands/CleanCommand.php b/src/Commands/CleanCommand.php index 35ac875..573d40b 100644 --- a/src/Commands/CleanCommand.php +++ b/src/Commands/CleanCommand.php @@ -4,6 +4,7 @@ use Awssat\Visits\Models\Visit; use Illuminate\Console\Command; +use Awssat\Visits\DataEngines\EloquentEngine; class CleanCommand extends Command { @@ -20,7 +21,7 @@ public function handle() { $currentEngine = config('visits.engine') ?? ''; - if($currentEngine == 'eloquent') { + if($currentEngine == EloquentEngine::class) { $this->cleanEloquent(); } } diff --git a/src/config/visits.php b/src/config/visits.php index dfb9520..46640a9 100755 --- a/src/config/visits.php +++ b/src/config/visits.php @@ -6,7 +6,7 @@ | Database Engine & Connection Name |-------------------------------------------------------------------------- | - | Supported Engines: "redis", "eloquent" + | Supported Engines: \Awssat\Visits\DataEngines\RedisEngine::class, \Awssat\Visits\DataEngines\EloquentEngine::class | Connection Name: see config/database.php | */ From 690899a3004e125886073baec758aa45bd1b1949 Mon Sep 17 00:00:00 2001 From: Remx Date: Tue, 11 Apr 2023 18:42:07 +0800 Subject: [PATCH 2/2] if currentEngine is EloquentEngine::class or its subclass, then exec cleanEloquent command. --- src/Commands/CleanCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/CleanCommand.php b/src/Commands/CleanCommand.php index 573d40b..63cd45e 100644 --- a/src/Commands/CleanCommand.php +++ b/src/Commands/CleanCommand.php @@ -21,7 +21,7 @@ public function handle() { $currentEngine = config('visits.engine') ?? ''; - if($currentEngine == EloquentEngine::class) { + if($currentEngine == EloquentEngine::class || is_subclass_of($currentEngine, EloquentEngine::class)) { $this->cleanEloquent(); } }