Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.

Overview

Laravel Befriended

CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models

🀝 Supporting

If you are using one or more Renoki Co. open-source packages in your production apps, in presentation demos, hobby projects, school projects or so, sponsor our work with Github Sponsors. πŸ“¦

πŸš€ Installation

Install the package:

$ composer require rennokki/befriended

Publish the config:

$ php artisan vendor:publish --provider="Rennokki\Befriended\BefriendedServiceProvider" --tag="config"

Publish the migrations:

$ php artisan vendor:publish --provider="Rennokki\Befriended\BefriendedServiceProvider" --tag="migrations"

πŸ™Œ Usage

The power of example is better here. This package allows you simply to assign followers, blockings or likes without too much effort. What makes the package powerful is that you can filter queries using scopes out-of-the-box.

$alice = User::where('name', 'Alice')->first();
$bob = User::where('name', 'Bob')->first();
$tim = User::where('name', 'Tim')->first();

$alice->follow($bob);

$alice->following()->count(); // 1
$bob->followers()->count(); // 1

User::followedBy($alice)->get(); // Just Bob shows up
User::unfollowedBy($alice)->get(); // Tim shows up

Following

To follow other models, your model should use the CanFollow trait and Follower contract.

use Rennokki\Befriended\Traits\CanFollow;
use Rennokki\Befriended\Contracts\Follower;

class User extends Model implements Follower {
    use CanFollow;
    ...
}

The other models that can be followed should use CanBeFollowed trait and Followable contract.

use Rennokki\Befriended\Traits\CanBeFollowed;
use Rennokki\Befriended\Contracts\Followable;

class User extends Model implements Followable {
    use CanBeFollowed;
    ...
}

If your model can both follow & be followed, you can use Follow trait and Following contract.

use Rennokki\Befriended\Traits\Follow;
use Rennokki\Befriended\Contracts\Following;

class User extends Model implements Following {
    use Follow;
    ...
}

Let's suppose we have an User model which can follow and be followed. Within it, we can now check for followers or follow new users:

$zuck = User::where('name', 'Mark Zuckerberg')->first();
$user->follow($zuck);

$user->following()->count(); // 1
$zuck->followers()->count(); // 1

Now, let's suppose we have a Page model, than can only be followed:

use Rennokki\Befriended\Traits\CanBeFollowed;
use Rennokki\Befriended\Contracts\Followable;

class Page extends Model implements Followable {
    use CanBeFollowed;
    ...
}

By default, if querying following() and followers() from the User instance, the relationships will return only User instances. If you plan to retrieve other instances, such as Page, you can pass the model name or model class as an argument to the relationships:

$zuckPage = Page::where('username', 'zuck')->first();

$user->follow($zuckPage);
$user->following()->count(); // 0, because it doesn't follow any User instance
$user->following(Page::class)->count(); // 1, because it follows only Zuck's page.

On-demand, you can check if your model follows some other model:

$user->isFollowing($friend);
$user->follows($friend); // alias

Some users might want to remove followers from their list. The Followable trait comes with a revokeFollower method:

$friend->follow($user);

$user->revokeFollower($friend);

Note: Following, unfollowing or checking if following models that do not correctly implement CanBeFollowed and Followable will always return false.

Filtering followed/unfollowed models

To filter followed or unfollowed models (which can be any other model) on query, your model which you will query should use the Rennokki\Befriended\Scopes\FollowFilterable trait.

If your User model can only like other Page models, your Page model should use the trait mentioned.

$bob = User::where('username', 'john')->first();
$alice = User::where('username', 'alice')->first();

User::followedBy($bob)->get(); // You will get no results.
User::unfollowedBy($bob)->get(); // You will get Alice.

$bob->follow($alice);
User::followedBy($bob)->get(); // Only Alice pops up.

Blocking

Most of the functions are working like the follow feature, but this is helpful when your models would like to block other models.

Use CanBlock trait and Blocker contract to allow the model to block other models.

use Rennokki\Befriended\Traits\CanBlock;
use Rennokki\Befriended\Contracts\Blocker;

class User extends Model implements Blocker {
    use CanBlock;
    ...
}

Adding CanBeBlocked trait and Blockable contract sets the model able to be blocked.

use Rennokki\Befriended\Traits\CanBeBlocked;
use Rennokki\Befriended\Contracts\Blockable;

class User extends Model implements Blockable {
    use CanBeBlocked;
    ...
}

For both, you should be using Block trait & Blocking contract:

use Rennokki\Befriended\Traits\Block;
use Rennokki\Befriended\Contracts\Blocking;

class User extends Model implements Blocking {
    use Block;
    ...
}

Most of the methods are the same:

$user->block($user);
$user->block($page);
$user->unblock($user);

$user->blocking(); // Users that this user blocks.
$user->blocking(Page::class); // Pages that this user blocks.
$user->blockers(); // Users that block this user.
$user->blockers(Page::class); // Pages that block this user.

$user->isBlocking($page);
$user->blocks($page); // alias to isBlocking

Filtering blocked models

Blocking scopes provided takes away from the query the models that are blocked. Useful to stop showing content when your models blocks other models.

Make sure that the model that will be queried uses the Rennokki\Befriended\Scopes\BlockFilterable trait.

$bob = User::where('username', 'john')->first();
$alice = User::where('username', 'alice')->first();

User::withoutBlockingsOf($bob)->get(); // You will get Alice and Bob as results.

$bob->block($alice);
User::withoutBlockingsOf($bob)->get(); // You will get only Bob as result.

Liking

Apply CanLike trait and Liker contract for models that can like:

use Rennokki\Befriended\Traits\CanLike;
use Rennokki\Befriended\Contracts\Liker;

class User extends Model implements Liker {
    use CanLike;
    ...
}

CanBeLiked and Likeable trait can be used for models that can be liked:

use Rennokki\Befriended\Traits\CanBeLiked;
use Rennokki\Befriended\Contracts\Likeable;

class Page extends Model implements Likeable {
    use CanBeLiked;
    ...
}

Planning to use both, use the Like trait and Liking contact:

use Rennokki\Befriended\Traits\Like;
use Rennokki\Befriended\Contracts\Liking;

class User extends Model implements Liking {
    use Like;
    ...
}

As you have already got started with, these are the methods:

$user->like($user);
$user->like($page);
$user->unlike($page);

$user->liking(); // Users that this user likes.
$user->liking(Page::class); // Pages that this user likes.
$user->likers(); // Users that like this user.
$user->likers(Page::class); // Pages that like this user.

$user->isLiking($page);
$user->likes($page); // alias to isLiking

Filtering liked content

Filtering liked content can make showing content easier. For example, showing in the news feed posts that weren't liked by an user can be helpful.

The model you're querying from must use the Rennokki\Befriended\Scopes\LikeFilterable trait.

Let's suppose there are 10 pages in the database.

$bob = User::where('username', 'john')->first();
$page = Page::find(1);

Page::notLikedBy($bob)->get(); // You will get 10 results.

$bob->like($page);
Page::notLikedBy($bob)->get(); // You will get only 9 results.
Page::likedBy($bob)->get(); // You will get one result, the $page

Follow requests

This is similar to the way Instagram allows you to request follow of a private profile.

To follow other models, your model should use the CanFollow trait and Follower contract.

use Rennokki\Befriended\Traits\CanFollow;
use Rennokki\Befriended\Contracts\Follower;

class User extends Model implements Follower {
    use CanFollow;
    ...
}

The other models that can be followed should use CanBeFollowed trait and Followable contract.

use Rennokki\Befriended\Traits\CanBeFollowed;
use Rennokki\Befriended\Contracts\Followable;

class User extends Model implements Followable {
    use CanBeFollowed;
    ...
}

If your model can both follow & be followed, you can use Follow trait and Following contract.

use Rennokki\Befriended\Traits\Follow;
use Rennokki\Befriended\Contracts\Following;

class User extends Model implements Following {
    use Follow;
    ...
}

Let's suppose we have an User model which can follow and be followed. Within it, we can now check for follower requests or request to follow a users:

$zuck = User::where('name', 'Mark Zuckerberg')->first();
$user->followRequest($zuck);

$user->followRequests()->count(); // 1
$zuck->followerRequests()->count(); // 1
$user->follows($zuck); // false
$zuck->acceptFollowRequest($user); // true
$user->follows($zuck); // true

Now, let's suppose we have a Page model, than can only be followed:

use Rennokki\Befriended\Traits\CanBeFollowed;
use Rennokki\Befriended\Contracts\Followable;

class Page extends Model implements Followable {
    use CanBeFollowed;
    ...
}

You can then request or cancel the follow requests:

$user->followRequest($zuck);
$user->cancelFollowRequest($zuck);

The one being followed can accept or decline the requests:

$zuck->acceptFollowRequest($user);
$zuck->declineFollowRequest($user);

By default, if querying followRequests() and followerRequests() from the User instance, the relationships will return only User instances.

If you plan to retrieve other instances, such as Page, you can pass the model name or model class as an argument to the relationships:

$zuckPage = Page::where('username', 'zuck')->first();

$user->followRequest($zuckPage);
$user->followRequests()->count(); // 0, because it does not have any requests from any User instance
$user->followerRequests(Page::class)->count(); // 1, because it has a follow request for Zuck's page.

Note: Requesting, accepting, declining or checking if following models that do not correctly implement CanBeFollowed and Followable will always return false.

πŸ› Testing

vendor/bin/phpunit

🀝 Contributing

Please see CONTRIBUTING for details.

πŸ”’ Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

πŸŽ‰ Credits

Comments
  • Add option to request follow like Instagrams private profiles.

    Add option to request follow like Instagrams private profiles.

    Hello, this is my first PHP contribution so I hope I have done everything and not missed anything.

    This allows you to request follow of a model where the model can accept / decline the request. If the request is accepted the user is added to the following list. I Implemented it in the CanBeFollowedand CanFollow and is only optional.

    Sending a request

    $user->followRequest($zuck);
    

    Canceling a request

    $user->cancelFollowRequest($zuck);
    

    Accepting a request

    $zuck->acceptFollowRequest($user);
    

    Declining a request

    $zuck->declineFollowRequest($user);
    
    opened by joveice 21
  • Optimize the queries with eager loading

    Optimize the queries with eager loading

    So I have the following code

    PostResource.php

    public function toArray($request)
     {
           return [
             'author' => new UserResource($this->author),
                'likesCount' => $this->likes_count,
                'isLiked' => $this->is_liked,
               'commentsCount' => $this->comments_count,
               'text' => $this->text,
               'created_at' => $this->created_at,
                'updated_at' => $this->updated_at,
                'id' => $this->id,
           ];
       ` }
    

    UserResource.php

    return [ 
                'id' => $this->id,
                'first_name' => $this->first_name,
                'last_name' => $this->last_name,
                'username' => $this->username,
                'gender' => $this->gender,
                'birthday' => $this->birthday,
                'email' => $this->email,
                'email_verified' => !!$this->email_verified_at,
                'isFollowMe' => $this->isFollowing($authUser),
                'isFollowedByMe' => $authUser->isFollowing($this->resource),
                'isBlockedByMe' => $authUser->isBlocking($this->resource),
                'followersCount' => $this->followers_count,
                'followingCount' => $this->following_count
            ];
    

    PostController.php

    public function index()
        {
            $user = Auth::user();
            $followersPost = Post
                ::with(['author' => function ($query) {
                    $query->withCount('followers', 'following');
                }])->withCount('comments', 'likes')
                ->whereHas('author', function ($query) use ($user) {
                    $query->followedBy($user);
                })
                ->orWhere('author_id', $user->id)
                ->latest()
                ->paginate(7);
            return PostResource::collection($followersPost);
        }
    

    Is there a method to optimize the queries? I mean it does 18 queries just for 3 posts ;( . I tried to search on google but find nothing

    opened by radudiaconu0 9
  • Minor versions shouldn't make incompatible API changes

    Minor versions shouldn't make incompatible API changes

    Hello, Thanks for the great package.

    In the readme file, you mentioned moving from a minor version to another cause changing traits used which we can say are incompatible API changes that shouldn't be done in a minor version changing please check semantic versioning.

    opened by ScSherifTarek 6
  • Laravel 9.x

    Laravel 9.x

    This pull request includes changes from your build using the "Shift Workbench".

    Before merging, you need to:

    • Checkout the shift-build-2349 branch
    • Review all comments for additional changes
    • Thoroughly test your application

    Don't hesitate to send your feedback to [email protected] or share your :heart: for Shift on Twitter.

    opened by rennokki 4
  • [Feature Request] Could you add upvote/downvote features?

    [Feature Request] Could you add upvote/downvote features?

    Hi,

    Thanks for awsome package.

    I found your package useful. It will be more useful and maybe will get more uses if it has upvote/downvote features.

    It will be redundant if I write a new package myself because the codebase is similar to current features (Like/Follow,...).

    So, could you add upvote/downvote features to this package?

    Thank you,

    Khanh

    wontfix 
    opened by dinhkhanh 4
  • Bump actions/cache from 3.0.5 to 3.0.11

    Bump actions/cache from 3.0.5 to 3.0.11

    Bumps actions/cache from 3.0.5 to 3.0.11.

    Release notes

    Sourced from actions/cache's releases.

    v3.0.11

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/cache/compare/v3...v3.0.11

    v3.0.10

    • Fix a bug with sorting inputs.
    • Update definition for restore-keys in README.md

    v3.0.9

    • Enhanced the warning message for cache unavailability in case of GHES.

    v3.0.8

    What's Changed

    • Fix zstd not working for windows on gnu tar in issues.
    • Allow users to provide a custom timeout as input for aborting cache segment download using the environment variable SEGMENT_DOWNLOAD_TIMEOUT_MIN. Default is 60 minutes.

    v3.0.7

    What's Changed

    • Fix for the download stuck problem has been added in actions/cache for users who were intermittently facing the issue. As part of this fix, new timeout has been introduced in the download step to stop the download if it doesn't complete within an hour and run the rest of the workflow without erroring out.

    v3.0.6

    What's Changed

    • Add example for clojure lein project dependencies by @​shivamarora1 in PR actions/cache#835
    • Update toolkit's cache npm module to latest. Bump cache version to v3.0.6 by @​pdotl in PR actions/cache#887
    • Fix issue #809 where cache save/restore was failing for Amazon Linux 2 runners due to older tar version
    • Fix issue #833 where cache save was not working for caching github workspace directory

    New Contributors

    Full Changelog: https://github.com/actions/cache/compare/v3...v3.0.6

    Changelog

    Sourced from actions/cache's changelog.

    3.0.5

    • Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. (PR)

    3.0.6

    • Fixed #809 - zstd -d: no such file or directory error
    • Fixed #833 - cache doesn't work with github workspace directory

    3.0.7

    • Fixed #810 - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour.

    3.0.8

    • Fix zstd not working for windows on gnu tar in issues #888 and #891.
    • Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable SEGMENT_DOWNLOAD_TIMEOUT_MIN. Default is 60 minutes.

    3.0.9

    • Enhanced the warning message for cache unavailablity in case of GHES.

    3.0.10

    • Fix a bug with sorting inputs.
    • Update definition for restore-keys in README.md

    3.0.11

    • Update toolkit version to 3.0.5 to include @actions/core@^1.10.0
    • Update @actions/cache to use updated saveState and setOutput functions from @actions/core@^1.10.0
    Commits
    • 9b0c1fc Merge pull request #956 from actions/pdotl-version-bump
    • 18103f6 Fix licensed status error
    • 3e383cd Update RELEASES
    • 43428ea toolkit versioon update and version bump for cache
    • 1c73980 3.0.11
    • a3f5edc Merge pull request #950 from rentziass/rentziass/update-actions-core
    • 831ee69 Update licenses
    • b9c8bfe Update @​actions/core to 1.10.0
    • 0f20846 Merge pull request #946 from actions/Phantsure-patch-2
    • 862fc14 Update README.md
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    wontfix dependencies github_actions 
    opened by dependabot[bot] 3
  • Bump codecov/codecov-action from 3.1.0 to 3.1.1

    Bump codecov/codecov-action from 3.1.0 to 3.1.1

    Bumps codecov/codecov-action from 3.1.0 to 3.1.1.

    Release notes

    Sourced from codecov/codecov-action's releases.

    3.1.1

    What's Changed

    New Contributors

    Full Changelog: https://github.com/codecov/codecov-action/compare/v3.1.0...v3.1.1

    Changelog

    Sourced from codecov/codecov-action's changelog.

    3.1.1

    Fixes

    • #661 Update deprecation warning
    • #593 Create codeql-analysis.yml
    • #712 README: fix typo
    • #725 fix: Remove a blank row
    • #726 Update README.md with correct badge version
    • #633 Create scorecards-analysis.yml
    • #747 fix: add more verbosity to validation
    • #750 Regenerate scorecards-analysis.yml
    • #774 Switch to v3
    • #783 Fix network entry in table
    • #791 Trim arguments after splitting them
    • #769 Plumb failCi into verification function.

    Dependencies

    • #713 build(deps-dev): bump typescript from 4.6.3 to 4.6.4
    • #714 build(deps): bump node-fetch from 3.2.3 to 3.2.4
    • #724 build(deps): bump github/codeql-action from 1 to 2
    • #717 build(deps-dev): bump @​types/jest from 27.4.1 to 27.5.0
    • #729 build(deps-dev): bump @​types/node from 17.0.25 to 17.0.33
    • #734 build(deps-dev): downgrade @​types/node to 16.11.35
    • #723 build(deps): bump actions/checkout from 2 to 3
    • #733 build(deps): bump @​actions/github from 5.0.1 to 5.0.3
    • #732 build(deps): bump @​actions/core from 1.6.0 to 1.8.2
    • #737 build(deps-dev): bump @​types/node from 16.11.35 to 16.11.36
    • #749 build(deps): bump ossf/scorecard-action from 1.0.1 to 1.1.0
    • #755 build(deps-dev): bump typescript from 4.6.4 to 4.7.3
    • #759 build(deps-dev): bump @​types/node from 16.11.36 to 16.11.39
    • #762 build(deps-dev): bump @​types/node from 16.11.39 to 16.11.40
    • #746 build(deps-dev): bump @​vercel/ncc from 0.33.4 to 0.34.0
    • #757 build(deps): bump ossf/scorecard-action from 1.1.0 to 1.1.1
    • #760 build(deps): bump openpgp from 5.2.1 to 5.3.0
    • #748 build(deps): bump actions/upload-artifact from 2.3.1 to 3.1.0
    • #766 build(deps-dev): bump typescript from 4.7.3 to 4.7.4
    • #799 build(deps): bump openpgp from 5.3.0 to 5.4.0
    • #798 build(deps): bump @​actions/core from 1.8.2 to 1.9.1
    Commits
    • d9f34f8 release: update changelog and version to 3.1.1 (#828)
    • 0e9e7b4 Plumb failCi into verification function. (#769)
    • 7f20bd4 build(deps): bump @​actions/core from 1.8.2 to 1.9.1 (#798)
    • 13bc253 build(deps): bump openpgp from 5.3.0 to 5.4.0 (#799)
    • 5c0da1b Trim arguments after splitting them (#791)
    • 68d5f6d Fix network entry in table (#783)
    • 2a829b9 Switch to v3 (#774)
    • 8e09eaf build(deps-dev): bump typescript from 4.7.3 to 4.7.4 (#766)
    • 39e2229 build(deps): bump actions/upload-artifact from 2.3.1 to 3.1.0 (#748)
    • b2b7703 build(deps): bump openpgp from 5.2.1 to 5.3.0 (#760)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    wontfix dependencies github_actions 
    opened by dependabot[bot] 3
  • Bump actions/cache from 3.0.1 to 3.0.2

    Bump actions/cache from 3.0.1 to 3.0.2

    Bumps actions/cache from 3.0.1 to 3.0.2.

    Release notes

    Sourced from actions/cache's releases.

    v3.0.2

    This release adds the support for dynamic cache size cap on GHES.

    Changelog

    Sourced from actions/cache's changelog.

    Releases

    3.0.0

    • Updated minimum runner version support from node 12 -> node 16
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    wontfix dependencies github_actions 
    opened by dependabot[bot] 3
  • Update doctrine/dbal requirement from ^2.10 to ^3.1

    Update doctrine/dbal requirement from ^2.10 to ^3.1

    Updates the requirements on doctrine/dbal to permit the latest version.

    Release notes

    Sourced from doctrine/dbal's releases.

    3.1.1

    Release 3.1.1

    3.1.1

    • Total issues resolved: 1
    • Total pull requests resolved: 8
    • Total contributors: 5

    Bug,Indexes,Platforms

    Bug

    Improvement,Test Suite,Tools

    Documentation

    CI,Cache,Deprecation,Static Analysis

    Character Encoding,Connections,MySQL,Test Suite

    Commits
    • 8e0fde2 Merge branch '2.13.x' into 3.1.x
    • 4c1a55f Merge pull request #4680 from morozov/disable-debug-stack-logger
    • 308a152 Disable DebugStack logger in the test suite
    • 8dd39d2 Merge pull request #4679 from morozov/phpunit-9.5.5
    • 920b9f1 Update PHPUnit to 9.5.5
    • e817657 Merge pull request #4674 from derrabus/merge/2.13.x
    • 69f9247 Merge branch '2.13.x'
    • f1453c5 Merge pull request #4673 from derrabus/docs/new-execute-api
    • c0935b6 Document a non-deprecated way to interact with prepared statements
    • 590a30b Use better example for data retrieval
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies php 
    opened by dependabot[bot] 3
  • Can't follow models with MorphMap

    Can't follow models with MorphMap

    Probably linked with #47 but I wanted to create a new issue with the current code

    When using morphMap, Laravel will not use the fully qualified class name, which breaks the current implementation of getModelMorphClass.

    for example using 'user' => 'App\Models\User' starting from isFollowing

      /**
       * Check if the current model is following another model.
       *
       * @param  \Illuminate\Database\Eloquent\Model  $model
       * @return bool
       */
      public function isFollowing($model): bool
      {
          if (! $model instanceof Followable && ! $model instanceof Following) {
              return false;
          }
    
          return ! is_null(
              $this
                  ->following((new $model)->getMorphClass()) // will be 'user'
                  ->find($model->getKey())
          );
      }
    

    Now in following

        /**
         * Relationship for models that this model is currently following.
         *
         * @param  null|\Illuminate\Database\Eloquent\Model  $model
         * @return mixed
         */
        public function following($model = null)
        {
            // $model === 'user'
            $modelClass = $this->getModelMorphClass($model);
    
            return $this
                ->morphToMany($modelClass, 'follower', 'followers', 'follower_id', 'followable_id')
                ->withPivot(['followable_type', 'accepted'])
                ->wherePivot('followable_type', $modelClass)
                ->wherePivot('follower_type', $this->getMorphClass())
                ->wherePivot('accepted', true)
                ->withTimestamps();
        }
    

    and finally, in getModelMorphClass

        /**
         * Get the model's morph class to act as the main resource.
         *
         * @param  string|null  $model
         * @return string
         */
        protected function getModelMorphClass($model = null)
        {
            return $model
                // FIXME: $model is still 'user' and Not 'App\Models\User' which causes exception
                ? (new $model)->getMorphClass()
                : $this->getCurrentModelMorphClass();
        }
    

    Screen Shot 2021-04-17 at 7 27 40 PM

    Hope this helps

    bug wontfix 
    opened by pascalboucher 3
  • [question] Is it possible to filtering liked content by model type

    [question] Is it possible to filtering liked content by model type

    Hello,

    Thank you for your work on this package.

    Is it possible to filter the liked content by model type when multiple models are likable?

    Eg.. if user and pages are likable, is it possible to get only pages liked by Bob?

    opened by imClement 3
  • Bump actions/cache from 3.0.5 to 3.2.2

    Bump actions/cache from 3.0.5 to 3.2.2

    Bumps actions/cache from 3.0.5 to 3.2.2.

    Release notes

    Sourced from actions/cache's releases.

    v3.2.2

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/cache/compare/v3.2.1...v3.2.2

    v3.2.1

    What's Changed

    Full Changelog: https://github.com/actions/cache/compare/v3.2.0...v3.2.1

    v3.2.0

    What's Changed

    New Contributors

    ... (truncated)

    Changelog

    Sourced from actions/cache's changelog.

    3.0.5

    • Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. (PR)

    3.0.6

    • Fixed #809 - zstd -d: no such file or directory error
    • Fixed #833 - cache doesn't work with github workspace directory

    3.0.7

    • Fixed #810 - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour.

    3.0.8

    • Fix zstd not working for windows on gnu tar in issues #888 and #891.
    • Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable SEGMENT_DOWNLOAD_TIMEOUT_MINS. Default is 60 minutes.

    3.0.9

    • Enhanced the warning message for cache unavailablity in case of GHES.

    3.0.10

    • Fix a bug with sorting inputs.
    • Update definition for restore-keys in README.md

    3.0.11

    • Update toolkit version to 3.0.5 to include @actions/core@^1.10.0
    • Update @actions/cache to use updated saveState and setOutput functions from @actions/core@^1.10.0

    3.1.0-beta.1

    • Update @actions/cache on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. (issue)

    3.1.0-beta.2

    • Added support for fallback to gzip to restore old caches on windows.

    3.1.0-beta.3

    • Bug fixes for bsdtar fallback if gnutar not available and gzip fallback if cache saved using old cache action on windows.

    3.2.0-beta.1

    • Added two new actions - restore and save for granular control on cache.

    3.2.0

    • Released the two new actions - restore and save for granular control on cache

    3.2.1

    • Update @actions/cache on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. (issue)
    • Added support for fallback to gzip to restore old caches on windows.
    • Added logs for cache version in case of a cache miss.

    3.2.2

    • Reverted the changes made in 3.2.1 to use gnu tar and zstd by default on windows.
    Commits
    • 4723a57 Revert compression changes related to windows but keep version logging (#1049)
    • d1507cc Merge pull request #1042 from me-and/correct-readme-re-windows
    • 3337563 Merge branch 'main' into correct-readme-re-windows
    • 60c7666 save/README.md: Fix typo in example (#1040)
    • b053f2b Fix formatting error in restore/README.md (#1044)
    • 501277c README.md: remove outdated Windows cache tip link
    • c1a5de8 Upgrade codeql to v2 (#1023)
    • 9b0be58 Release compression related changes for windows (#1039)
    • c17f4bf GA for granular cache (#1035)
    • ac25611 docs: fix an invalid link in workarounds.md (#929)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
  • Update phpunit/phpunit requirement from ^9.5.21 to ^9.5.27

    Update phpunit/phpunit requirement from ^9.5.21 to ^9.5.27

    Updates the requirements on phpunit/phpunit to permit the latest version.

    Changelog

    Sourced from phpunit/phpunit's changelog.

    [9.5.27] - 2022-MM-DD

    Fixed

    • #5113: PHP error instead of PHPUnit error when trying to create test double for readonly class

    [9.5.26] - 2022-10-28

    Fixed

    • #5076: Test Runner does not warn about conflicting options

    [9.5.25] - 2022-09-25

    Added

    • #5042: Support Disjunctive Normal Form types

    Fixed

    • #4966: TestCase::assertSame() (and related exact comparisons) must compare float exactly

    [9.5.24] - 2022-08-30

    Added

    • #4931: Support null and false as stand-alone types
    • #4955: Support true as stand-alone type

    Fixed

    • #4913: Failed assert() should show a backtrace
    • #5012: Memory leak in ExceptionWrapper

    [9.5.23] - 2022-08-22

    Changed

    • #5033: Do not depend on phpspec/prophecy

    [9.5.22] - 2022-08-20

    Fixed

    • #5015: Ukraine banner unreadable on black background
    • #5020: PHPUnit 9 breaks loading of PSR-0/PEAR style classes
    • #5022: ExcludeList::addDirectory() does not work correctly

    [9.5.21] - 2022-06-19

    ... (truncated)

    Commits
    • a2bc7ff Prepare release
    • 1b09a9a Exclude source file with PHP 8.2 syntax
    • ac259bc Update Psalm baseline
    • 9e0968d Update ChangeLog
    • 8635ff9 Skip test on PHP < 8.2
    • faa1515 Implement logic to blocks readonly classes to be doubled.
    • 5c6e811 Merge branch '8.5' into 9.5
    • cc19735 Update tools
    • c5d3542 Assert that we have a DOMElement here
    • a653302 Document collected/iterated type using Psalm template
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies php 
    opened by dependabot[bot] 1
Releases(4.1.0)
Owner
Renoki Co.
Settled on the internet and building awesome stuff!
Renoki Co.
Laravel Ban simplify blocking and banning Eloquent models.

Laravel Ban Introduction Laravel Ban simplify management of Eloquent model's ban. Make any model bannable in a minutes! Use case is not limited to Use

cybercog 879 Dec 30, 2022
Laravel Nova Ban simplify blocking and banning Eloquent models.

Laravel Nova Ban Introduction Behind the scenes cybercog/laravel-ban is used. Contents Installation Usage Prepare bannable model Prepare bannable mode

cybercog 39 Sep 29, 2022
Advanced Laravel models filtering capabilities

Advanced Laravel models filtering capabilities Installation You can install the package via composer: composer require pricecurrent/laravel-eloquent-f

Andrew Malinnikov 162 Oct 30, 2022
This Laravel Nova package allows you to manage media and media fields

Nova Media Hub This Laravel Nova package allows you to manage media and media fields. Requirements php: >=8.0 laravel/nova: ^4.0 Features Media Hub UI

outl1ne 25 Dec 22, 2022
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About LivewireUI Spotlight LivewireUI Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel application.

Livewire UI 792 Jan 3, 2023
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About Wire Elements Spotlight Wire Elements Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel applic

Wire Elements 790 Dec 27, 2022
Open source for selling social media accounts or accounts on other platforms.

SELLACC - Open Source Selling Accounts SELLACC is open source for selling social media accounts or accounts on other platforms. ⚠️ We not update sourc

PHAM DUC THANH 6 Nov 17, 2022
A non-blocking stream abstraction for PHP based on Amp.

amphp/byte-stream is a stream abstraction to make working with non-blocking I/O simple. Installation This package can be installed as a Composer depen

Amp 317 Dec 22, 2022
Ebansos (Electronic Social Assistance) is a web application that provides citizen data management who will receive social assistance to avoid misdirection assistance from public service/government.

E Bansos Ebansos (Electronic Social Assistance) is a web application that provides citizen data management who will receive social assistance to avoid

Azvya Erstevan I 12 Oct 12, 2022
A package to generate YouTube-like IDs for Eloquent models

Laravel Hashids This package provides a trait that will generate hashids when saving any Eloquent model. Hashids Hashids is a small package to generat

Ξ›Π³i 25 Aug 31, 2022
Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel 5.

Laravel-Mediable Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel. Features Filesystem-driven appro

Plank Design 654 Dec 30, 2022
Library that offers Input Filtering based on Annotations for use with Objects. Check out 2.dev for 2.0 pre-release.

DMS Filter Component This library provides a service that can be used to filter object values based on annotations Install Use composer to add DMS\Fil

Rafael Dohms 89 Nov 28, 2022
A base API controller for Laravel that gives sorting, filtering, eager loading and pagination for your resources

Bruno Introduction A Laravel base controller class and a trait that will enable to add filtering, sorting, eager loading and pagination to your resour

Esben Petersen 165 Sep 16, 2022
A simple and modern approach to stream filtering in PHP

clue/stream-filter A simple and modern approach to stream filtering in PHP Table of contents Why? Support us Usage append() prepend() fun() remove() I

Christian LΓΌck 1.5k Dec 29, 2022
In Laravel, we commonly face the problem of adding repetitive filtering code, this package will address this problem.

Filterable In Laravel, we commonly face the problem of adding repetitive filtering code, sorting and search as well this package will address this pro

Zoran Shefot Bogoevski 1 Jun 21, 2022
This project uses dflydev/dot-access-data to provide simple output filtering for cli applications.

FilterViaDotAccessData This project uses dflydev/dot-access-data to provide simple output filtering for applications built with annotated-command / Ro

Consolidation 44 Jul 19, 2022
An Eloquent Way To Filter Laravel Models And Their Relationships

Eloquent Filter An Eloquent way to filter Eloquent Models and their relationships Introduction Lets say we want to return a list of users filtered by

Eric Tucker 1.5k Jan 7, 2023
Use auto generated UUID slugs to identify and retrieve your Eloquent models.

Laravel Eloquent UUID slug Summary About Features Requirements Installation Examples Compatibility table Alternatives Tests About By default, when get

Khalyomede 25 Dec 14, 2022
Record created by, updated by and deleted by on Eloquent models automatically.

quarks/laravel-auditors Record created by, updated by and deleted by (if SoftDeletes added) on Eloquent models automatically. Installation composer re

Quarks 3 Jun 13, 2022