Download the PHP package therealedatta/fork-cyrildewit-eloquent-viewable-tags without Composer

On this page you can find all versions of the php package therealedatta/fork-cyrildewit-eloquent-viewable-tags. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fork-cyrildewit-eloquent-viewable-tags

Eloquent Viewable

Packagist Travis branch StyleCI Codecov branch Total Downloads license

Note: This is an unstable branch!

This Laravel >= 5.5 package allows you to associate views with Eloquent models.

Once installed you can do stuff like this:

Overview

Eloquent Viewable is a flexible and easy to use Laravel package to associate views with Eloquent Models. It's designed for large and small projects. Instead of having a simple counter that increments by each view, this package will provide you a full history of the views.

This package is not built with the intent to collect analytical data. It is made to simply store the views of a Laravel Eloquent model. You would this package for models like: Post, Video, Course and Hotel, but of course, you can use this package as you want.

Features

Here are some of the main features:

Feature requests are very welcome! Create an issue with [Feature Request] as prefix or send a pull request.

Documentation

In this documentation, you will find some helpful information about the use of this Laravel package.

Table of contents

  1. Getting Started
    • Requirements
    • Installation
  2. Usage
    • Preparing your models
    • Storing views
    • Storing views with expiry date
    • Storing views under a tag
    • Retrieving views counts
    • Order models by views count
    • Views helper
  3. Configuration
    • Queue the ProcessView job
    • Extending
  4. Recipes
    • Creating helper methods for frequently used period formats

Getting Started

Requirements

The Eloquent Viewable package requires PHP 7+ and Laravel 5.5+.

Lumen is not supported!

Version information

Version Illuminate Status PHP Version

<<<<<<< HEAD | 3.0 | 5.5 - 5.7 | In Development | >= 7.1.0 | | 2.0 | 5.5 - 5.7 | Active support | >= 7.0.0 |

| 3.0 | 5.5 - 5.6 | Active support | >= 7.0.0 | | 2.0 | 5.5 - 5.6 | Active support | >= 7.0.0 |

feature/tags | 1.0 | 5.5 - 5.6 | Bug fixes only | >= 7.0.0 |

Installation

You can install this package via composer using:

Optionally, you can add the service provider in the config/app.php file. Otherwise this can be done via automatic package discovery.

You can publish the migration with:

After publishing the migration file you can create the views table by running the migrations. However, if you already have a table named views, you can change this name in the config. Search for 'models->view->table_name' and change the value to something unique.

You can publish the config file with:

Usage

In the following sections, you will find information about the usage of this package.

Preparing your models

To make an Eloquent model viewable just add the Viewable trait to your model definition. This trait provides various methods to allow you to save views, retrieve views counts and order your items by views count.

Storing views

Adding a new view to a model can be achieved really easy by calling the ->addView() method on your viewable model.

The best place where you should put it is inside your controller. If you're following the CRUD standard, it would be the @show method.

A PostController might look something like this:

Note: If you want to queue this job, you can turn this on in the configuration! See the Queue the ProcessView job section!

Storing views with expiry date

If you want to add a delay between views from the same session, you can use the available addViewWithExpiryDate on your viewable model.

This method will add a new view to your model and it will add a record in the user's session. If you call this method multiple times, you will see that views count will not increment. After the current date time has passed the expiry date, a new view will be stored.

Storing views under a tag

In some cases you might want to have multiple counters for a viewable model. This can be easily achieved by passing an additional argument to the addView method.

And with expiry date:

Retrieving views counts

After adding the Viewable trait to your model, you will be able to call getViews() and getUniqueViews() on your viewable model. Both methods accepts an optional Period instance.

Period class

Be aware that the following code isn't valid PHP syntax!

Examples

Order models by views count

Retrieve Viewable models by views count

Retrieve Viewable models by unique views count

Views helper

Saving views

Saving views with expiry date

Saving views under a tag

Retrieving views counts

Get views by viewable type

To get the total number of views by a viewable type, you can use one of following methods.

Get most viewed viewables by type

Get the views count of viewables per period

Don't confuse this method with the Period class!

Configuration

Queue the ProcessView job

When calling the ->addView() method on your model, it will save a new view in the database with some data. Because this can slow down your application, you can turn queuing on by changing the value of store_new_view under jobs in the configuration file. Make sure that your app is ready for queuing. If not, see the official Laravel documentation for more information!

Extending

If you want to extend or replace one of the core classes with your own implementations, you can override them:

Note: Don't forget that all custom classes must implement their original interfaces

Replace View model with custom implementation

Replace ViewableService service with custom implementation

Replace CrawlerDetectAdapter class with custom implementation

Recipes

Creating helper methods for frequently used period formats

App\Models\Post

resources/views/post/show.blade.php

Upgrading

Please see UPGRADING for detailed upgrade guide.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

This project is licensed under the MIT License - see the LICENSE.md file for details.


All versions of fork-cyrildewit-eloquent-viewable-tags with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
illuminate/bus Version 5.5.*|5.6.*|5.7.*
illuminate/cache Version 5.5.*|5.6.*|5.7.*
illuminate/contracts Version 5.5.*|5.6.*|5.7.*
illuminate/cookie Version 5.5.*|5.6.*|5.7.*
illuminate/database Version 5.5.*|5.6.*|5.7.*
illuminate/http Version 5.5.*|5.6.*|5.7.*
illuminate/queue Version 5.5.*|5.6.*|5.7.*
illuminate/routing Version 5.5.*|5.6.*|5.7.*
illuminate/support Version 5.5.*|5.6.*|5.7.*
jaybizzle/crawler-detect Version ^1.0
nesbot/carbon Version ^1.22
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package therealedatta/fork-cyrildewit-eloquent-viewable-tags contains the following files

Loading the files please wait ....