Download the PHP package jobmetric/laravel-like without Composer
On this page you can find all versions of the php package jobmetric/laravel-like. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jobmetric/laravel-like
More information about jobmetric/laravel-like
Files in jobmetric/laravel-like
Package laravel-like
Short Description This is a like management package for Laravel that you can use in your projects.
License MIT
Homepage https://doc.jobmetric.net/package/laravel-like
Informations about the package laravel-like
Like for laravel
This is a like management package for Laravel that you can use in your projects.
Install via composer
Run the following command to pull in the latest version:
Documentation
This package evolves every day under constant development and integrates a diverse set of features. It is a must-have asset for Laravel enthusiasts and provides a seamless way to coordinate your projects with like and dislike base models.
In this package, you can use it seamlessly with any model that requires likes and dislikes.
Now let's move on to the main function.
Before doing anything, you must migrate after installing the package by composer.
Meet the HasLike
class, meticulously designed for integration into your model. This class automates essential tasks, ensuring a streamlined process for:
In the first step, you need to connect this class to your main model.
How is it used?
You can now use the HasLike
class for your model. The following example shows how to create a new post with a like:
The
likeIt
function is used to like the post. The first parameter is the user id, and the second parameter is the type of like. If you want to dislike, you can set it tofalse
.
Now we go to the functions that we have added to our model.
likeOne
like has one relationship
likes
like has many relationships
likeTo
scope locale for select like relationship
dislikeTo
scope locale for select disLike relationship
likesTo
scope locale for select likes relationship
dislikesTo
scope locale for select disLikes relationship
likeIt
This function is very important and is used to store user's likes and dislikes.
The
likeIt
function is used to like the post. The first parameter is the user id, and the second parameter is the type of like. If you want to dislike, you can set it tofalse
. user_id: user id type: like or dislike
likeCount
get count of likes
dislikeCount
get count of dislikes
loadLikeDislikeCount
This function helps to see the number of likes and dislikes of each object and loads it in the desired model.
loadLikeDislike
load like or disLike after model loaded
The
loadLikeDislike
function is used to load the likes and dislikes of the object after the model is loaded.
loadLikesDislikes
load likes or dislikes after model loaded
The
loadLikesDislikes
function is used to load the likes and dislikes of the object after the model is loaded.
isLikedDislikedBy
is liked or disliked by user
forgetLike
forget like or dislike
forgetLikes
forget likes or dislikes
Contributing
Thank you for considering contributing to the Laravel Like! The contribution guide can be found in the CONTRIBUTING.md.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-like with dependencies
laravel/framework Version >=9.19
jobmetric/laravel-package-core Version ^1.7