-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from cyrildewit/develop
Develop
- Loading branch information
Showing
11 changed files
with
175 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
use Illuminate\Support\Facades\Session; | ||
|
||
/** | ||
* Laravel wrapper for SessionHistory. | ||
* Class SessionHistory. | ||
* | ||
* @copyright Copyright (c) 2017 Cyril de Wit (http://www.cyrildewit.nl) | ||
* @author Cyril de Wit ([email protected]) | ||
|
@@ -27,7 +27,6 @@ class SessionHistory | |
*/ | ||
public function __construct() | ||
{ | ||
// Set primary Session Key | ||
$this->primarySessionKey = config('page-visits-counter.sessions.primary-session-key', 'page-visits-counter.history'); | ||
} | ||
|
||
|
@@ -43,12 +42,10 @@ public function addToSession(Model $model, Carbon $expires_at) | |
// Make unique key from the inserted model | ||
$uniqueKey = $this->fromCamelCaseToDashes(class_basename($model)); | ||
|
||
// Remove expired visits froms session | ||
$this->removeExpiredVisitsFromSession($uniqueKey); | ||
|
||
// Check if the item is visited, if not add to session | ||
if (! $this->isItemVisited($uniqueKey, $model->id)) { | ||
// Push it to the session | ||
Session::push($this->primarySessionKey.'.'.$uniqueKey, [ | ||
'visitable_id' => $model->id, | ||
'expires_at' => $expires_at, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,35 +5,27 @@ | |
use Illuminate\Support\ServiceProvider; | ||
use Cyrildewit\PageVisitsCounter\Contracts\PageVisit as PageVisitContract; | ||
|
||
/** | ||
* Class PageVisitsCounterServiceProvider. | ||
* | ||
* @copyright Copyright (c) 2017 Cyril de Wit (http://www.cyrildewit.nl) | ||
* @author Cyril de Wit ([email protected]) | ||
* @license https://opensource.org/licenses/MIT MIT License | ||
*/ | ||
class PageVisitsCounterServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register bindings in the container. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// Merge the config file | ||
$this->mergeConfigFrom( | ||
__DIR__.'/../config/page-visits-counter.php', | ||
'page-visits-counter' | ||
); | ||
} | ||
|
||
/** | ||
* Bootstrap PageVisitsCounter application services. | ||
* Bootstrap the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
// Publish config file | ||
$this->publishes([ | ||
__DIR__.'/../config/page-visits-counter.php' => $this->app->configPath('page-visits-counter.php'), | ||
], 'config'); | ||
|
||
// Publish migration file only if it doesn't exist | ||
// Publish migration file only if it doesn't exists | ||
if (! class_exists('CreatePageVisitsTable')) { | ||
$timestamp = date('Y_m_d_His', time()); | ||
|
||
|
@@ -42,19 +34,32 @@ public function boot() | |
], 'migrations'); | ||
} | ||
|
||
// Register Model Bindings | ||
$this->registerModelBindings(); | ||
} | ||
|
||
/** | ||
* Regiser the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// Merge the config file | ||
$this->mergeConfigFrom( | ||
__DIR__.'/../config/page-visits-counter.php', | ||
'page-visits-counter' | ||
); | ||
} | ||
|
||
/** | ||
* Register Model Bindings. | ||
* | ||
* @return void | ||
*/ | ||
protected function registerModelBindings() | ||
{ | ||
$config = $this->app->config['page-visits-counter.models']; | ||
$config = $this->app->config['page-visits-counter']; | ||
|
||
$this->app->bind(PageVisitContract::class, $config['page-visit']); | ||
$this->app->bind(PageVisitContract::class, $config['page_visit_model']); | ||
} | ||
} |
Oops, something went wrong.