@@ -134,10 +134,12 @@ public static function getPublishAction(): Action
134134 ->keyBindings (['command+p ' , 'ctrl+p ' ])
135135 ->color ('secondary ' )
136136 ->action (function ($ livewire ): void {
137- // $livewire instanceof CreateRecord ? $livewire->create() : $livewire->save();
138- $ livewire ->redirect (static ::getUrl ('view ' , ['record ' => $ livewire ->record ]));
139- });
140- // ->visible(fn ($livewire): bool => $livewire instanceof CreateRecord || $livewire instanceof EditRecord);
137+ $ livewire ->data ['status ' ] = 'published ' ;
138+ $ livewire ->data ['published_at ' ] = now ();
139+ $ livewire ->save ();
140+ $ livewire ->redirect (static ::getUrl ('view ' , ['record ' => $ livewire ->record , 'lang ' => $ livewire ->lang ]));
141+ })
142+ ->visible (fn ($ livewire ): bool => $ livewire instanceof CreateRecord || $ livewire instanceof EditRecord);
141143 }
142144
143145 public static function getSaveAndCreateAnotherAction (): Action
@@ -148,7 +150,7 @@ public static function getSaveAndCreateAnotherAction(): Action
148150 ->button ()
149151 ->action (function ($ livewire ): void {
150152 $ livewire instanceof CreateRecord ? $ livewire ->create () : $ livewire ->save ();
151- $ livewire ->redirect (static ::getUrl ('create ' ));
153+ $ livewire ->redirect (static ::getUrl ('create ' , [ ' lang ' => $ livewire -> lang ] ));
152154 })
153155 ->visible (fn ($ livewire ): bool => $ livewire instanceof CreateRecord);
154156 }
@@ -160,7 +162,7 @@ public static function getCancelAction(): Action
160162 ->keyBindings (['escape ' ])
161163 ->color ('secondary ' )
162164 ->outlined ()
163- ->url (fn () => static ::getUrl ('index ' ));
165+ ->url (fn () => static ::getUrl ('index ' , [ ' lang ' => request ()-> query ( ' lang ' )] ));
164166 // ->visible(fn ($livewire): bool => $livewire instanceof CreateRecord);
165167 }
166168
@@ -173,7 +175,7 @@ public static function getDeleteAction(): Action
173175 ->extraAttributes (attributes: ['class ' => 'w-full ' ])
174176 ->action (function ($ livewire ): void {
175177 $ livewire ->record ->delete ();
176- $ livewire ->redirect (static ::getUrl ('index ' ));
178+ $ livewire ->redirect (static ::getUrl ('index ' , [ ' lang ' => request ()-> query ( ' lang ' )] ));
177179 })
178180 ->keyBindings (['delete ' ])
179181 ->visible (fn ($ livewire ): bool => $ livewire instanceof EditRecord)
@@ -187,7 +189,7 @@ public static function getEditAction(): Action
187189 ->color ('primary ' )
188190 ->extraAttributes (attributes: ['class ' => 'w-full ' ])
189191 ->keyBindings (['command+e ' , 'ctrl+e ' ])
190- ->url (fn ($ record ) => static ::getUrl ('edit ' , ['record ' => $ record ]))
192+ ->url (fn ($ record, $ livewire ) => static ::getUrl ('edit ' , ['record ' => $ record, ' lang ' => $ livewire -> lang ]))
191193 ->visible (fn ($ livewire ): bool => $ livewire instanceof ViewRecord);
192194 }
193195
0 commit comments