cyrildewit/eloquent-viewable
Eloquent Viewable is a minimalistic analytics package for Laravel that adds seamless view tracking to Eloquent models, with cooldowns, queued recording, unique counts, and period-based queries.
Visitor now receives the cookie jar through its constructor (Illuminate\Contracts\Cookie\QueueingFactory) and reads the existing visitor cookie from the injected request, instead of going through the Cookie facade (breaking only for subclasses that override the constructor)views() helper now throws an InvalidArgumentException when given a class name that does not implement Contracts\Viewable, instead of a TypeError from deeper inside the packageViewableObserver now skips soft deletes and only destroys views on a force delete, so a restored model keeps its view count. If you relied on a soft delete purging views, call views($model)->destroy() yourselfCooldownManager built the session key to forget from an empty array_column() result, so it removed the whole namespace instead of the one expired entryVisitor::hasDoNotTrackHeader() always returning false; it looked the header up as HTTP_DNT, which is the $_SERVER key, while Laravel's header bag exposes it as DNT (the Visitor::DNT constant now holds 'DNT')orderByUniqueViews() and withViewsCount(unique: true) ordering and counting by total views instead of distinct visitors; Laravel drops the extra select added inside a withCount constraint, so the distinct count is now passed as the aggregate expressionSee the upgrade guide for detailed migration instructions.
^8.5Views contract now declares the existing useVisitor() method (breaking only for classes that implement Contracts\Views directly)cooldown() and remember() parameters on the Views contract to be typed DateTimeInterface|int|nullscopeWithinPeriod() method on the View contract to declare a void return typePeriod::getStartDateTime()/getEndDateTime() to return ?CarbonInterfaceInvalidPeriod and ViewRecordException exceptions as final (breaking only for code that extends them)Viewable contract now uses [@mixin](https://github.com/mixin) \Illuminate\Database\Eloquent\Model instead of redeclaring the getKey() and getMorphClass() methodsView contract now uses [@mixin](https://github.com/mixin) \Illuminate\Database\Eloquent\Model and declares the existing scopeCollection() method (breaking only for classes that implement Contracts\View directly)create_views_table migration stub (typed properties and return types)visitor column in the create_views_table migration stub from text to string (VARCHAR(255)) so it can be indexed directly (only affects newly published migrations)models.view.connection and cache.store to null, so they now defer to the application's default database connection and cache store instead of reading env('DB_CONNECTION') and the deprecated env('CACHE_DRIVER') (only affects newly published config)Period as a final, immutable (readonly) value object; relative periods are now built with the new Support\PeriodInterval and Support\PeriodAnchor enums, and date parsing defers to Carbon::make() (the factory methods, getStartDateTime()/getEndDateTime(), and the cache-key format are unchanged)illuminate/* now requires ^13.0)nesbot/carbon now requires ^3.0)getStartDateTimeString(), getEndDateTimeString(), getStartDateTimestamp() and getEndDateTimestamp() getters from PeriodPeriod::PAST_* and Period::SUB_* constants and the sub(), subToday() and subNow() static helpersPeriod::getSubType(), getSubValue(), hasFixedDateTimes(), setStartDateTime(), setEndDateTime(), setFixedDateTimes(), setSubType() and setSubValue() methods (Period is now immutable)expires_at is restored as a string instead of a Carbon instance (#326)Full Changelog: https://github.com/cyrildewit/eloquent-viewable/compare/v7.1.0...v7.1.1
Full Changelog: https://github.com/cyrildewit/eloquent-viewable/compare/v7.0.5...v7.0.6
Full Changelog: https://github.com/cyrildewit/eloquent-viewable/compare/v7.0.4...v7.0.5
Full Changelog: https://github.com/cyrildewit/eloquent-viewable/compare/v7.0.3...v7.0.4
Full Changelog: https://github.com/cyrildewit/eloquent-viewable/compare/v7.0.2...v7.0.3
Full Changelog: https://github.com/cyrildewit/eloquent-viewable/compare/v7.0.1...v7.0.2
Full Changelog: https://github.com/cyrildewit/eloquent-viewable/compare/v6.1.0...v7.0.1
remember method in Views contract. The $lifetime variable has now a default value of null.remember method in Views class. The $lifetime variable has now a default value of null.bool return typehint to record method in Views contract.void return typehint to destroy method in Views contract.ViewRecordException will be thrown when trying to record a view for a viewable type.ViewRecorded event will be fired when a new view is recorded.Views typehint to global views() function.bool return typehint to isCrawler method in CrawlerDetector contract.composer.json to ^7.4|^8.0.View instance has been moved into its own method protected function createView(): View.$viewable argument of the forViewable method in Views contract cannot be nullable anymore.orderByViews and orderByUniqueViews query scope in Viewable contract and InteractsWithViews trait.withViewsCount query scope in InteractsWithViews trait.Period class typehint to $period argument of period method in Views contract.$name argument nullable in Views contract.ip method in Visitor contract to ?string.DateTime typehint to DateTimeInterface in InvalidPeriod exception.lifetime_in_minutes option from config file.count method of Views class to count all views, including the collections (#241).CyrildeWit\EloquentViewable\Contracts\Views to resolve Views instance from container.null) for viewable in views() helper.Views contract.Visitor contract.Visitor class which represents the current visitor.getViewableTypeSlug() to CacheKey::class.orderByViews query scope to Viewable trait.orderByUniqueViews query scope to Viewable trait.withViewsCount query scope to Viewable trait.CyrildeWit\EloquentViewable\Viewable trait has been renamed to CyrildeWit\EloquentViewable\InteractsWithViews.session.key to cooldown.key in configuration file.Views class constructor arguments. Added the Visitor as first argument and removed VisitorCookieRepository $visitorCookieRepository, rawlerDetector $crawlerDetector and IpAddressResolver $ipAddressResolver.$this->crawlerDetector in Views with new Visitor class implementation.requestHasDoNotTrackHeader in Views with new Visitor class implementation.increments to bigIncrements in views table migration.^6.0|^7.0.getConnectionName(), getDatabaseName(), getModelSlug() and getKeySlug in CacheKey::class.ViewSessionHistory class to CooldownMananger.CooldownManager class. The Illuminate\Contracts\Config\Repository has been added as first parameter and the cooldown key is now retrieved from this instance.Views class now implements the Views contract.Views class has been changed.Facades/Views to src/ and renamed it to ViewsFacade.views() helper now supports viewable types.nesbot/carbon ^1.22.overrideIpAddress method from the Views class.overrideVisitor method from the Views class.requestHasDoNotTrackHeader method from Views class.$viewableType argument from constructor of CacheKey::class.fromViewableType method from CacheKey::class.HeaderResolver contract and class.IpAddressResolver contract and class.uniqueVisitor() scope from View model.Enums\SortDirection class.OrderByViewsScope class.countByType method from the Views class.VisitorCookieRepository (logic is move to the Visitor class).SortDirection enum class that contains a DESCENDING and ASCENDING constantOrderByViewsScope class that can order a query by views based on some optionscollection($collection) query scope to View modelorderByViews and orderByUniqueViews query scopeCacheKey class with a new improved approach to making keys for the cachegetStartDateTimestamp and getEndDateTimestamp methods to the Period class for internal usestring $collection = null argument to push, createNamespaceKey and createViewableKey methods in ViewSessionHistoryoverrideIpAddress method of the Views class. Please use the new useIpAddress(string $address) method instead.overrideVisitor method of the Views class. Please use the new useVisitor(string $visitor) method instead.orderByViews and orderByUniqueViews query scope with the new OrderByViewsScope classstring type declaration from the getTable method in the View model class #165Support\Key class with its referencesdelayInSession method without getting an errordelayInSession isn't working properlyViews class with facadeIpAddressResolver contract with implementationHeaderResolver contract with implementationVisitorCookieRepository classviewscollection column to views table shemawithinPeriod scope to View modeluniqueVisitor scope to View modelViewable contractviews() helperisBot method name to isCrawler in CrawlerDetector contract and updated the CrawlerDetectAdapter$detector property from protected to private5.7.* of illuminate/config to composer.jsonpublishable/config to config/create_views_table stub with real migration file and load it inside the service providerPeriod classPeriod class to the Key classViewTracker classViewableService classProcessView jobupdate_views_table migration file from resources/database/migrationsilluminate/bus as dependencyilluminate/queue as dependencyilluminate/routing as dependencyorderByViewsCount scope doesn't adhere to connection prefixvisitorHow can I help you explore Laravel packages today?