Code Monkey home page Code Monkey logo

laravel-like's Issues

like posts by company instead of user

hello
In my app the user has a company profile in addition to the his profile ( like Facebook pages).
I need to like a Post by this company profile using company_id for example.
How to implement that with your package please ?
thanks

How to get user all posts total like?

If user has 5 posts and each post has 5 likes, so there should be all posts total likes = 25.
I think it should like this

$user()->totalLikes()->count()

Composer wont install because of vulnerabilities

Composer fails installing, audit throws this message:

+-------------------+----------------------------------------------------------------------------------+
| Package           | guzzlehttp/guzzle                                                                |
| CVE               | CVE-2022-31091                                                                   |
| Title             | Change in port should be considered a change in origin                           |
| URL               | https://github.com/guzzle/guzzle/security/advisories/GHSA-q559-8m2m-g699         |
| Affected versions | >=7,<7.4.5|>=4,<6.5.8                                                            |
| Reported at       | 2022-06-20T22:24:00+00:00                                                        |
+-------------------+----------------------------------------------------------------------------------+
+-------------------+----------------------------------------------------------------------------------+
| Package           | guzzlehttp/guzzle                                                                |
| CVE               | CVE-2022-31090                                                                   |
| Title             | CURLOPT_HTTPAUTH option not cleared on change of origin                          |
| URL               | https://github.com/guzzle/guzzle/security/advisories/GHSA-25mq-v84q-4j7r         |
| Affected versions | >=7,<7.4.5|>=4,<6.5.8                                                            |
| Reported at       | 2022-06-20T22:24:00+00:00                                                        |

Empty likers() collection

// likers count
$post->likers;

The likers count always returning empty collection!

However overwriting writing the relation method like this works fine:

public function likers()
    {
        return $this->morphToMany(User::class, 'likable', 'likes');
    }

It is working well in laravel-follow used branch. Please help!

某个用户 like 的数据、分页获取,可否获取文章的用户信息?

单独获取 某篇文章,这样是可以获取到用户信息的

$likers = $post->likers()->paginate(20);

foreach($likers as $user) {
    // echo $user->name;
}

但是我如果 Get user likes with pagination:

$likes = $user->likes()->with('likable')->paginate(20);

foreach ($likes as $like) {
    $like->likable; // App\Post instance
}

这种方式好像没有办法获取用户的详细信息,超哥是否有其他的方法?

Like and Unlike Event not dispatching!

Please note that I extended the package traits CanLiked, CanBeLiked in my App/Libraries/Like namespace. Then used the extended traits in the target models. Thanks

BadMethodCallException

"message": "Call to undefined method Illuminate\Database\Eloquent\Builder::like()",
"exception": "BadMethodCallException",
......

Post Controller:
public function likePost($id)
{
$user = User::where('id', auth()->user()->id);
$post = Post::find($id);

    $user->like($post);

    return response(['message' => 'Post Like successfully!']);
}

Post Model:

How to get user Like on post collection?

$posts = Post::with('post_images')->with('user')->withCount('comments')->orderBy('created_at', 'desc')->get();

how to get total likes for each post?

thank you

Separate Follow package

Just love you for your open source effort!

Can you please also create a separate Follow package without relation type column?

It will be more scalable for millions of users.

Thanks again.

composer install is not getting all the files.

May be it's not a issue but i was using your laravel follow unfollow package and it's working fine but when i try to install the like package and try to publish the configuration and the migration it says that the file is not found and when i try to create the like it always throws an exception saying => Class name must be a valid object or a string <= but the both models are configured as the instruction given also the post and the user are both objects when i check dd it.

Error Publishing Migrations and Config

This package doesn't seem to create or publish migrations in my Laravel 9 installation.

The command php artisan vendor:publish --provider="Overtrue\\LaravelLike\\LikeServiceProvider" --tag=migrations throws a warning: No publishable resources for tag [migrations].

The warning is the same for --tag=configs as well.

Also, I might be wrong, but the package doesn't create a default likes table migration which I can use. Do I have to manually create a likes table or is the package supposed to create a default migration for me?

Support for laravel cursor paginate?

I attempted to use this packages attachLikeStatus on a cursorPaginated eloquent model. Which doesn't seem to work. With normal pagination it works fine.

$listings = Listing::filterByRequest($request)
                       ->cursorPaginate($perPage);

$currentUser = Auth::user();
if (Auth::check()) {
    $listings = $currentUser->attachLikeStatus($listings);
}

I added a CursorPaginator handler to Liker.php trait and now the above works:

case $likeables instanceof CursorPaginator:
    $likeables = \collect($likeables->items());
    break;

Likes Count Issue

After upgrading the package from 2.0 to 4.0, the following error displayed in the post index view:

Screen Shot 2021-02-25 at 8 03 21 PM

Querying the posts via Laravel as follows:

$posts = Post::withCount('likes')
            ->whereIn('user_id', function ($query) {
                $query->select('following_id')
                    ->from('user_follower')
                    ->where('follower_id', auth()->id());
            })->orWhere('user_id', auth()->id())
            ->latest()
            ->paginate(10);

Created like button as a Vue component to display the count and update it when a post is liked or unliked.

The count from the Post model is fetched via "likes_count" attribute.

Issue appears to be a bug in the package.

Likes relationship

I would recommend to add likes relationship:

public function likes(): \Illuminate\Database\Eloquent\Relations\MorphMany
{
    return $this->morphMany(config('like.like_model'), 'likeable');
}

In the same way as you did in Favorites. It is useful for delete all linked likes to the object, etc.

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.