Download the PHP package edram/laravel-interactions without Composer

On this page you can find all versions of the php package edram/laravel-interactions. 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 laravel-interactions

Laravel Interactions

Latest Version on Packagist Tests Total Downloads

One polymorphic interaction system for likes, favorites, subscriptions, follows, votes, and custom actions.

AI skill

Install the package usage skill to give your coding agent the public APIs, setup rules, and examples from this repository:

Installation

Set the default actor model used by relations such as likers(), followers(), subscribers(), and voters():

The key_type configuration supports bigint, uuid, and ulid. Configure it before running the migration. Actors and interactables stored in the same interactions table must use the same key type.

Model setup

Actors use Interacts. Targets use Interactable. A model such as User that can both create and receive interactions uses both traits.

Both sides are polymorphic. A User, Team, or any other Eloquent model using Interacts can act on any model using Interactable.

For a smaller model API, combine the core concerns with only the semantic concerns the model needs:

Actor semantic concerns require HasInteractions. Target semantic concerns require ReceivesInteractions. Interacts and Interactable remain the convenient all-in-one alternatives.

Actor models

Any Eloquent model using Interacts, or HasInteractions with selected Actor concerns, can initiate interactions. default_actor is not an allowlist; it only chooses the related model when a target-side relation omits its Actor class.

A direct Eloquent relation returns one Actor model type. Query interaction records and eager load the polymorphic actor relation when all types are required:

When no Actor class is passed, the package resolves default_actor and then falls back to auth.providers.users.model. Pass the class explicitly to override either default.

Built-in interactions

Interaction Actor API Target API
Like like, unlike, toggleLike, hasLiked, likes, likedItems isLikedBy, likers, likersFor
Favorite favorite, unfavorite, toggleFavorite, hasFavorited, favorites, favoriteItems isFavoritedBy, favoriters
Subscribe subscribe, unsubscribe, toggleSubscribe, hasSubscribed, subscriptions, subscribedItems isSubscribedBy, subscribers
Follow follow, unfollow, toggleFollow, isFollowing, following isFollowedBy, followers
Vote vote, upvote, downvote, cancelVote, hasVoted, votes isVotedBy, voters, upvoters, downvoters, totalVotes

like, favorite, subscribe, and follow are idempotent. Calling them repeatedly does not create duplicate records. A vote uses one record per actor and target; changing direction or weight updates that record.

To query a non-default actor model, pass its class explicitly:

Custom interactions

Custom action names are lowercase slugs up to 64 characters. Strings and string-backed enums are accepted.

Use the optional signed integer value for weighted actions and metadata for additional structured data.

Feed status

Attach several interaction states to a model, collection, or paginator with one interaction query:

null means no interaction exists, true means an interaction without a value exists, and an integer is the stored value.

Events and deletion

The package dispatches these events only when persistence actually changes:

Hard-deleting an actor or interactable removes its interactions. Soft deletion preserves them until the model is force deleted.

Development

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-interactions with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^12.0 || ^13.0
illuminate/database Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
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 edram/laravel-interactions contains the following files

Loading the files please wait ...