GithubHelp home page GithubHelp logo

Comments (6)

antonkomarev avatar antonkomarev commented on May 11, 2024 1

(?) 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.

antonkomarev avatar antonkomarev commented on May 11, 2024

(?) 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.

antonkomarev avatar antonkomarev commented on May 11, 2024

(?) 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.

antonkomarev avatar antonkomarev commented on May 11, 2024

(?) 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.

antonkomarev avatar antonkomarev commented on May 11, 2024

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.

antonkomarev avatar antonkomarev commented on May 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.