Download the PHP package toneflix-code/social-interactions without Composer

On this page you can find all versions of the php package toneflix-code/social-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 social-interactions

Laravel Social Interactions

Test & Lint Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require codecov

Laravel Social Interactions adds to your project the ability to create social interactions like saves, votes, likes, dislikes, reactions, Etc. with your models.

Contents

  1. Use Cases
  2. Installation
  3. Package Discovery
  4. Configuration
  5. Usage
    • Likes
    • Dislikes
    • Reactions
    • Votes
    • Saving
    • Accessing the interaction relationship
    • Accessing the interactor relationship
    • Accessing the interaction relationship for the interacting model
    • Get Model Interaction for a specific Interactor
    • Get Interaction Data
    • Accessing saved items relationship
    • Accessing saved items relationship for the interacting model
  6. Testing
  7. Changelog
  8. Contributing
  9. Security
  10. Credits
  11. License

Use Cases

  1. Voting System (Upvoting and Downvoting)
  2. Bookmarking System
  3. Liking and Reaction System
  4. Anything that requires a third party user to approve or reject.

Installation

  1. Install the package via composer:

  2. Publish resources (migrations and config files) [Optional]:

    • Config File

      After publishing, the config file can be found in config/social-interactions.php

    • Migration Files
  3. Before running migrations, you may want to take a look at the tables config if you want to customize the table names used by the package. Finally. run the migrations with the following command:

  4. Done!

Package Discovery

Laravel automatically discovers and publishes service providers but optionally after you have installed Laravel Fileable, open your Laravel config file config/app.php and add the following lines.

In the $providers array add the service providers for this package.

Add the facade of this package to the $aliases array.

Configuration

If you published

Usage

For a model to be able to interact with other models, it has to be using the ToneflixCode\SocialInteractions\Traits\CanSocialInteract trait.

Also the model which is to be intracted with will implement the ToneflixCode\SocialInteractions\Traits\HasSocialInteractions trait.

At this point you're are ready to begin creating social interactions with your models.

Likes

To leave a like, call the leaveReaction method on the model with the CanSocialInteract trait, passing the model with the HasSocialInteractions trait as the first parameter and either of 0, 1, false, true as the second. If a model is already liked, a second call will unlike the model. Likes are only available if the enable_reactions config property is set to false, otherwise this will set the reaction to the first reaction defined in the available_reactions config property.

  1. Like

  2. Unlike

Check if a model has been liked

To check if a model has been liked, call the isLiked method on the model with the HasSocialInteractions trait, passing the model with the CanSocialInteract trait as the only parameter.

Dislikes

To leave a dislike, call the leaveReaction method on the model with the CanSocialInteract trait, passing the model with the HasSocialInteractions trait as the first parameter and dislikee as the second. If a model is already disliked, a second call will undislike the model. Dislikes are only available if the enable_dislikes config property is set to true.

Check if a model has been disliked

To check if a model has been disliked, call the isDisliked method on the model with the HasSocialInteractions trait, passing the model with the CanSocialInteract trait as the only parameter.

Reactions

Reactions can be enabled and available reactions can be set in the config file. To leave a reaction, call the leaveReaction method on the model with the CanSocialInteract trait, passing the model with the HasSocialInteractions trait as the first parameter and the desired reaction as the second.

Check if a model has been reacted to

To check if a model has been reacted to, call the isReacted method on the model with the HasSocialInteractions trait, passing the model with the CanSocialInteract trait as the only parameter.

Votes

To vote for a model, call the giveVote method on the model with the HasSocialInteractions trait, passing the model with the CanSocialInteract trait as the first parameter and either of true or false as the second. If a model is already voted and the multiple_votes config property is set to true, subsequent calls will add to the vote count of the model. By default, voted models can not be unvoted for, to allow unvotes, set the enable_unvote config property to true.

  1. Vote

  2. Unvote

Check if a model has been voted for

To check if a model has been voted for, call the isVoted method on the model with the HasSocialInteractions trait, passing the model with the CanSocialInteract trait as the only parameter.

Saving

To mark a model as saved, call the toggleSave method on the model with the HasSocialInteractions trait, passing the model with the CanSocialInteract trait as the first parameter and either of true or false as the second.

  1. Save

  2. Unsave

Check if a model has been saved

To check if a model has been saved, call the isSaved method on the model with the HasSocialInteractions trait, passing the model with the CanSocialInteract trait as the only parameter.

Optionally, you can pass the name of a list as a second parameter to check if the model has been saved to the list.

Saving to a list

To save a model to a list, call the toggleSaveToList method on the model with the HasSocialInteractions trait, passing the model with the CanSocialInteract trait as the first parameter and either of true or false as the second and the list name as the third.

  1. Save

  2. Unsave

Retrieving your lists

To retrieve the names of all your saved lists, access the saved_social_lists property on the model with the CanSocialInteract trait. You get a collection with all the names.

Deleting lists

To delete a saved list, call the deleteSavedSocialList method on the model with the CanSocialInteract trait, passing the name of the desired list to delete as the only parameter or true to delete all lists.

OR

Accessing the interaction relationship

The interaction relationship can be accessed from the socialInteractions property or method (if you need finer grain control and access to the Eloquent builder instance) on the model with the HasSocialInteractions trait.

OR

Accessing the interactor relationship

The interactor relationship which represent the model (or user) that interacted with the model can be accessed from the interactor property or method (if you need finer grain control and access to the Eloquent builder instance) on the SocialInteraction model.

Accessing the interaction relationship for the interacting model

The interaction relationship for the interacting model can be accessed from the socialInteracts property or method (if you need finer grain control and access to the Eloquent builder instance) on the model with the CanSocialInteract trait.

OR

Get Model Interaction for a specific Interactor

To get the model interaction, call the modelInteraction method on the model with the HasSocialInteractions trait, passing the model with the CanSocialInteract trait as the only parameter. Since the package uses a single model for all interactions, this will return the SocialInteraction model for the current model with the HasSocialInteractions trait.

Get Interaction Data

For convinience, the package also provides the socialInteractionData method on the model with the HasSocialInteractions trait to help you quickly get the interaction stats for the model as a Laravel collection, passing the model with the CanSocialInteract trait as the only parameter will also attach the interaction states for the interacting model.

Example Output:

With Interactor:

Example Output:

Accessing saved items relationship

The saved items relationship can be accessed from the socialInteractionSaves property or method (if you need finer grain control and access to the Eloquent builder instance) on the model with the HasSocialInteractions trait.

OR

Accessing saved items relationship for the interacting model

The saved items relationship for the interacting model can be accessed from the savedSocialInteracts property or method (if you need finer grain control and access to the Eloquent builder instance) on the model with the CanSocialInteract trait.

OR

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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


All versions of social-interactions with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1|^8.2|^8.3
illuminate/support Version ^9.0|^10.0|^11.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 toneflix-code/social-interactions contains the following files

Loading the files please wait ....