22
33namespace Overtrue \LaravelFollow \Traits ;
44
5+ use function abort_if ;
6+ use function class_uses ;
7+ use function collect ;
58use Illuminate \Contracts \Pagination \Paginator ;
6- use Illuminate \Database \Eloquent \Builder ;
79use Illuminate \Database \Eloquent \Collection ;
810use Illuminate \Database \Eloquent \Model ;
9- use Illuminate \Database \Eloquent \Relations \BelongsToMany ;
1011use Illuminate \Database \Eloquent \Relations \HasMany ;
1112use Illuminate \Pagination \CursorPaginator ;
1213use Illuminate \Pagination \LengthAwarePaginator ;
1314use Illuminate \Support \Enumerable ;
1415use Illuminate \Support \LazyCollection ;
15- use InvalidArgumentException ;
16- use JetBrains \PhpStorm \ArrayShape ;
17- use Overtrue \LaravelFollow \Traits \Followable ;
18- use function abort_if ;
19- use function class_uses ;
20- use function collect ;
2116use function in_array ;
17+ use InvalidArgumentException ;
2218use function is_array ;
2319use function iterator_to_array ;
20+ use JetBrains \PhpStorm \ArrayShape ;
2421
2522/**
2623 * @property Collection $followings
2724 */
2825trait Follower
2926{
30- #[ArrayShape(['pending ' => " mixed " ])]
27+ #[ArrayShape(['pending ' => ' mixed ' ])]
3128 public function follow (Model $ followable ): array
3229 {
3330 if ($ followable ->is ($ this )) {
3431 throw new InvalidArgumentException ('Cannot follow yourself. ' );
3532 }
3633
37- if (!in_array (Followable::class, class_uses ($ followable ))) {
34+ if (! in_array (Followable::class, class_uses ($ followable ))) {
3835 throw new InvalidArgumentException ('The followable model must use the Followable trait. ' );
3936 }
4037
@@ -45,15 +42,15 @@ public function follow(Model $followable): array
4542 'followable_id ' => $ followable ->getKey (),
4643 'followable_type ' => $ followable ->getMorphClass (),
4744 ], [
48- 'accepted_at ' => $ isPending ? null : now ()
45+ 'accepted_at ' => $ isPending ? null : now (),
4946 ]);
5047
5148 return ['pending ' => $ isPending ];
5249 }
5350
5451 public function unfollow (Model $ followable ): void
5552 {
56- if (!in_array (Followable::class, class_uses ($ followable ))) {
53+ if (! in_array (Followable::class, class_uses ($ followable ))) {
5754 throw new InvalidArgumentException ('The followable model must use the Followable trait. ' );
5855 }
5956
@@ -67,7 +64,7 @@ public function toggleFollow(Model $followable): void
6764
6865 public function isFollowing (Model $ followable ): bool
6966 {
70- if (!in_array (Followable::class, class_uses ($ followable ))) {
67+ if (! in_array (Followable::class, class_uses ($ followable ))) {
7168 throw new InvalidArgumentException ('The followable model must use the Followable trait. ' );
7269 }
7370
@@ -84,7 +81,7 @@ public function isFollowing(Model $followable): bool
8481
8582 public function hasRequestedToFollow (Model $ followable ): bool
8683 {
87- if (!in_array (\Overtrue \LaravelFollow \Traits \Followable::class, \class_uses ($ followable ))) {
84+ if (! in_array (\Overtrue \LaravelFollow \Traits \Followable::class, \class_uses ($ followable ))) {
8885 throw new InvalidArgumentException ('The followable model must use the Followable trait. ' );
8986 }
9087
@@ -144,7 +141,7 @@ public function attachFollowStatus($followables, callable $resolver = null)
144141 break ;
145142 }
146143
147- abort_if (!($ followables instanceof Enumerable), 422 , 'Invalid $followables type. ' );
144+ abort_if (! ($ followables instanceof Enumerable), 422 , 'Invalid $followables type. ' );
148145
149146 $ followed = $ this ->followings ()->get ();
150147
0 commit comments