Comments (6)
(?) Magical attributes
Magical calls of the attributes $article->liked
& $article->disliked
could be dropped. Since it only Laravel related and doesn't give any benefits.
from laravel-love.
(?) LikeableService contract
Old
public function addLikeTo(Likeable $likeable, $type, $userId);
public function removeLikeFrom(Likeable $likeable, $type, $userId);
public function toggleLikeOf(Likeable $likeable, $type, $userId);
public function isLiked(Likeable $likeable, $type, $userId): bool;
New
Change methods argument order in LikeableService
contract and accept only strict types.
public function addLikeTo(Likeable $likeable, Liker $user, LikeType $type);
public function removeLikeFrom(Likeable $likeable, Liker $user, LikeType $type);
public function toggleLikeOf(Likeable $likeable, Liker $user, LikeType $type);
public function isLiked(Likeable $likeable, Liker $user, LikeType $type): bool;
from laravel-love.
(?) Strict types in Likeable model methods
Old
Methods likeBy
, dislikeBy
, isLikedBy
, isDislikedBy
, toggleLikedBy
, toggleDislikedBy
accepts argument $user
with values of:
null
what means it's called by current user;- explicit integer or string
user_id
attribute of the Liker; - model which implements
Cog\Contracts\Love\Liker\Models\Liker
.
$article->likeBy($user);
$article->dislikeBy($user);
$article->isLikedBy($user);
$article->isDislikedBy($user);
$article->toggleLikeBy($user);
$article->toggleDislikeBy($user);
New
It will be good to pass Liker
model to Likeable
methods likeBy
, dislikeBy
, isLikedBy
, isDislikedBy
, toggleLikeBy
, toggleDislikeBy
instead of user_id
.
$article->likeBy(Liker $user);
$article->dislikeBy(Liker $user);
$article->isLikedBy(Liker $user);
$article->isDislikedBy(Liker $user);
$article->toggleLikeBy(Liker $user);
$article->toggleDislikeBy(Liker $user);
from laravel-love.
(?) Assert likes by current user
Old
$article->isLikedBy();
$article->isDislikedBy();
New
We should throw ability to check likes by current user or we could add new helper methods if needed. Otherwise it's not explicit that check uses current user.
$article->isLikedByMe();
$article->isDislikedByMe();
from laravel-love.
Relationships
Old implementation
Relationships exists only in Likeable
model now:
// Likes and dislikes related to Likeable
$likesAndDislikes = $article->likesAndDislikes();
// Likes related to Likeable
$likes = $article->likes();
// Dislikes related to Likeable
$dislikes = $article->dislikes();
New implementation
Under discussion in #7.
from laravel-love.
Closing this issue since its outdated. I've completely revised an API of the next package version.
More details about v6: #15
from laravel-love.
Related Issues (20)
- NotAssignedToReactable exception when trying to access deleted item HOT 2
- Why is there a rate limit of 99.99? HOT 1
- Unable to use likeBy() method HOT 10
- Expose the datetime of reactions HOT 6
- Method Illuminate\Database\Eloquent\Collection::viaLoveReactant does not exist. HOT 1
- methods available for the view HOT 3
- eager loading HOT 2
- What is the rate? HOT 2
- seeding fails on: ReactionCounter for 'x' Reactant with ReactionType 'y' already exists. HOT 5
- Not working with database prefix HOT 2
- Add support for laravel 9 HOT 2
- Is there no place to see this working? HOT 6
- Does it work with factory or seeder? HOT 5
- How to stop queue-ing new jobs HOT 1
- Database Changes - Setup Instructions HOT 3
- Deprecated warnings HOT 4
- Remove laravel/legacy-factory dev dependency
- How do I narrow down the reactor's reaction? HOT 12
- Get Reacterable for soft deleted (trashed) users HOT 5
- Scope joinReactionCounterOfType not working when used with select HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-love.