Download the PHP package nr-type/like-dislike without Composer
On this page you can find all versions of the php package nr-type/like-dislike. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nr-type/like-dislike
More information about nr-type/like-dislike
Files in nr-type/like-dislike
Package like-dislike
Short Description This is a package for devs who want to use like dislike options in there applications, this is the easiest way to to that.
License MIT
Informations about the package like-dislike
Laravel Like Dislike Package
About Package
This is a package for developers who want to use like and dislike options in their applications, this is the easiest way to do that.
Installing
This package can be installed through Composer in your application :
Run the command.
Migration
After that run the Migration command :
Model Use
The model where you want to have like and dislike.
You just need to use NrType\LikeDislike\Traits\Likeable
and NrType\LikeDislike\Traits\Dislikeable
.
And inside the class use Likeable
and Dislikeable
.
You can use like dislike options in multiple Model
Multiple Model
are can be Comment
,Video
,Photo
.
Optional
Suppose you just only need Like option for your application.
Then you use NrType\LikeDislike\Traits\Likeable
and Likeable
.
Compatibility
Like
and Dislike
can work individually and also both are compatible to work with each other, suppose someone like the post and after some time later thinks that he/she wants to dislike the post. He/she just simply click the dislike button, and it will remove
his/her like
on that particular post and dislike
.
Uses in Controller
Like
Use like option in the post such as like 2 lines of code.
But
Suppose you want that someone's click
like button then it will like the post and again he click
liked button then it will unlike the post. Then here is removeLike()
. if User alreay like that post it will remove that particular like in the same method or if you want you can create another route and method to unlike the post.
DisLike
Use dislike in the post same as like in post. For dislike options again you have dislike()
and removeDislike()
Or
Likers and Dislikers on the Post
You can easily access likers and dislikers through likers()
and dislikers()
. default it will return with users id
,name
from users
table.
Or
Now here has somethings
likers()
and dislikers()
default return id
,name
but you maybe don't need id
, you may only need name
or your users database table doesn't have name
field, it can be first_name
,last_name
or maybe something else or maybe you need more then those fields. Here have a solution. You just pass a array
in side the method. It will return those fields data form users table.
Or
with()
relationship call in Controller
You can show likes
, dislikes
on posts and also want to show how many likes and dislike on posts with likeCounter
, dislikeCounter
.
Or
You may have comments
on posts
and you need comments
and also need likes
on particular comment
and how many likes
on comment
. Then you can use comments.likes
and comments.likeCounter
.
Additional options
hasLike()
, hasDislike()
is for check that logged in user has like or dislike in post or comment. It return boolean
. You can use hasLike()
hasDislike()
in blades file as well.
License
Like Dislike bucket is open-sourced software licensed under the MIT license.