@@ -15,33 +15,20 @@ class TableCells extends Component
1515
1616 public function __construct (
1717 public Translatable $ model ,
18- public string $ route_name = '' ,
19- public array $ route_params = [],
20- public string $ create_url = '' ,
2118 ) {
2219 $ this ->languages = Languages::allExceptCurrent ();
2320 }
2421
2522 public function getUrl (string $ action , string $ locale ): string
2623 {
27- $ params = filled ($ this ->route_params ) ? $ this ->route_params : $ this ->model ->getRouteParams ();
28-
29- // A big assumption here is that the last parameter in the route params is the model ID.
30- // If the action is 'create', we don't need the last parameter (usually the ID)
31- if ($ action === 'create ' ) {
32- $ params = array_slice ($ params , 0 , -1 ); // Remove the last parameter if it exists
33- }
24+ $ url = $ this ->model ->url ($ action , $ locale );
3425
3526 // If the model is we need to add "lang_parent" to the params
3627 if ($ this ->isModelDbTranslatable ()) {
37- $ params [ 'lang_parent ' ] = $ this ->model ->id ;
28+ $ url = add_query_arg ( 'lang_parent ' , $ this ->model ->id , $ url ) ;
3829 }
3930
40- return translate_route (
41- filled ($ this ->route_name ) ? $ this ->route_name : $ this ->model ->getRouteName () . '. ' . $ action ,
42- $ params ,
43- locale: $ locale ,
44- );
31+ return $ url ;
4532 }
4633
4734 public function isModelDbTranslatable (): bool
0 commit comments