33namespace App \Nova \Actions ;
44
55use Illuminate \Bus \Queueable ;
6- use Illuminate \Contracts \Queue \ShouldQueue ;
76use Illuminate \Queue \InteractsWithQueue ;
87use Illuminate \Support \Collection ;
98use Illuminate \Support \Str ;
@@ -32,6 +31,7 @@ public function __construct($modelName, $parentModel, $resourceId)
3231 public function addFields ($ fields )
3332 {
3433 $ this ->fields = $ fields ;
34+
3535 return $ this ;
3636 }
3737
@@ -44,14 +44,16 @@ public function addFields($fields)
4444 */
4545 public function handle (ActionFields $ fields , Collection $ models )
4646 {
47- $ model = app ('App\Models \\' .Str::studly ($ this ->modelName ));
48- foreach ($ this ->fields as $ field ) {
49- if (($ field ->resourceClass ?? null ) == null )
50- $ model ->{$ field ->attribute } = $ fields ->{$ field ->attribute };
47+ $ model = app ('App\Models \\' .Str::studly ($ this ->modelName ));
48+ foreach ($ this ->fields as $ field ) {
49+ if (($ field ->resourceClass ?? null ) == null ) {
50+ $ model ->{$ field ->attribute } = $ fields ->{$ field ->attribute };
5151 }
52- $ model ->{Str::snake ($ this ->parentModel . " id " )} = $ this ->resourceId ;
53- $ model ->save ();
52+ }
53+ $ model ->{Str::snake ($ this ->parentModel .' id ' )} = $ this ->resourceId ;
54+ $ model ->save ();
5455 }
56+
5557 /**
5658 * Get the fields available on the action.
5759 *
@@ -62,6 +64,4 @@ public function fields(NovaRequest $request)
6264 {
6365 return $ this ->fields ;
6466 }
65-
66-
6767}
0 commit comments