If you have published the config file of this package, you will have to copy the following snippet to your config file:
/*
|--------------------------------------------------------------------------
| Session Configuration
|--------------------------------------------------------------------------
*/
'session' => [
/*
* Everthing will be stored under the following key.
*/
'key' => 'cyrildewit.eloquent-viewable.session',
],
Take a look at the original file to find the right location.
There are no manual changes needed.
The package has been renamed from Laravel Page View Counter
to Eloquent Viewable
.
While v1.0.5
already required PHP 7.0 and higher, it is now added to the composer.json file.
The license has been changed from MIT
to Apache 2.0
.
You can install the new package via composer using:
composer require cyrildewit/eloquent-viewable
Replace CyrildeWit\PageViewCounter\PageViewCounterServiceProvider::class
with CyrildeWit\EloquentViewable\EloquentViewableServiceProvider::class
in providers.
If your app is in development, you can publish the new migration file with:
php artisan vendor:publish --provider="CyrildeWit\EloquentViewable\EloquentViewableServiceProvider" --tag="migrations"
Otherwise you can use the update_views_table
migration to upgrade. It can be found at resources/database/.
First you have to publish the new config file with:
php artisan vendor:publish --provider="CyrildeWit\EloquentViewable\EloquentViewableServiceProvider" --tag="config"
Read this config file and update the fields if needed!
- Replace
use CyrildeWit\PageViewCounter\Traits\HasPageViewCounter;
withuse CyrildeWit\EloquentViewable\Viewable;
. - Replace
use HasPageViewCounter;
withuse Viewable;
.
For example:
use Illuminate\Database\Eloquent\Model;
use CyrildeWit\EloquentViewable\Viewable;
class Post extends Model
{
use Viewable;
// ...
}
- Find all usages of
addPageView()
and replace it withaddView()
.
Note: this feature has been made available again in v2.1.0
! See the README!
- Find all usages of
addPageViewThatExpiresAt(<DateTime>)
and replace it withaddView()
.
- Find all usages of
getPageViews()
and replace it withgetViews()
. - Find all usages of
getPageViewsFrom(<DateTime>)
and replace it withgetViews(Period::since(<DateTime>))
. - Find all usages of
getPageViewsBefore(<DateTime>)
and replace it withgetViews(Period::upto(<DateTime>))
. - Find all usages of
getPageViewsBetween(<DateTime>)
and replace it withgetViews(Period::create(<DateTime>, <DateTime>))
. - Find all usages of
getUniquePageViews()
and replace it withgetUniqueViews()
. - Find all usages of
getUniquePageViewsFrom(<DateTime>)
and replace it withgetUniqueViews(Period::since(<DateTime>))
. - Find all usages of
getUniquePageViewsBefore(<DateTime>)
and replace it withgetUniqueViews(Period::upto(<DateTime>))
. - Find all usages of
getUniquePageViewsBetween(<DateTime>)
and replace it withgetUniqueViews(Period::create(<DateTime>, <DateTime>))
.
The DateTransformers feature has been removed from v2.0.0.