File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ public function followings()
190190 )->withPivot ('accepted_at ' )->withTimestamps ()->using (UserFollower::class);
191191 }
192192
193- public function attachFollowStatus ($ followables )
193+ public function attachFollowStatus ($ followables, callable $ resolver = null )
194194 {
195195 $ returnFirst = false ;
196196
@@ -214,7 +214,10 @@ public function attachFollowStatus($followables)
214214
215215 $ followed = $ this ->followings ()->wherePivot ('accepted_at ' , '!= ' , null )->pluck ('following_id ' );
216216
217- $ followables ->map (function (Model $ followable ) use ($ followed ) {
217+ $ followables ->map (function (Model $ followable ) use ($ followed , $ resolver ) {
218+ $ resolver = $ resolver ?? fn ($ m ) => $ m ;
219+ $ followable = $ resolver ($ followable );
220+
218221 if (\in_array (Followable::class, \class_uses ($ followable ))) {
219222 $ followable ->setAttribute ('has_followed ' , $ followed ->has ($ followable ->getKey ()));
220223 }
You can’t perform that action at this time.
0 commit comments