File tree Expand file tree Collapse file tree 1 file changed +13
-17
lines changed Expand file tree Collapse file tree 1 file changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -28,23 +28,19 @@ protected function setUp(): void
28
28
$ this ->tooltip (fn () => $ this ->resolveDescription ($ this ->getFromState ()));
29
29
$ this ->setActionAttributes ();
30
30
$ this ->action (function (Collection $ records , $ data ) {
31
- if (empty ($ data )) {
32
- $ records ->each (fn ($ record ) => $ record ->{$ this ->getAttribute ()}?->equals($ this ->getFromState ())
33
- && in_array (
34
- $ this ->getToState ()::getMorphClass (),
35
- $ record ->{$ this ->getAttribute ()}->transitionableStates (),
36
- )
37
- ? $ record ->{$ this ->getAttribute ()}->transitionTo ($ this ->getToStateClass ())
38
- : null );
39
- } else {
40
- $ records ->each (fn ($ record ) => $ record ->{$ this ->getAttribute ()}?->equals($ this ->getFromState ())
41
- && in_array (
42
- $ this ->getToState ()::getMorphClass (),
43
- $ record ->{$ this ->getAttribute ()}->transitionableStates (),
44
- )
45
- ? $ record ->{$ this ->getAttribute ()}->transitionTo ($ this ->getToStateClass (), $ data )
46
- : null );
47
- }
31
+ $ records ->each (callback: function ($ record ) use ($ data ) {
32
+ if ($ record ->{$ this ->getAttribute ()}->equals ($ this ->getFromState ())) {
33
+ if (empty ($ data )) {
34
+ if ($ record ->{$ this ->getAttribute ()}->canTransitionTo ($ this ->getToStateClass ())) {
35
+ return $ record ->{$ this ->getAttribute ()}->transitionTo ($ this ->getToStateClass ());
36
+ }
37
+ } else {
38
+ if ($ record ->{$ this ->getAttribute ()}->canTransitionTo ($ this ->getToStateClass (), $ data )) {
39
+ return $ record ->{$ this ->getAttribute ()}->transitionTo ($ this ->getToStateClass (), $ data );
40
+ }
41
+ }
42
+ }
43
+ });
48
44
});
49
45
}
50
46
You can’t perform that action at this time.
0 commit comments