From 777685d4466986b6a871712ad4cb93deed1e481d Mon Sep 17 00:00:00 2001 From: Dennis Elsinga Date: Mon, 18 Sep 2023 16:47:14 +0200 Subject: [PATCH 1/2] Allow more labels to be translated, added translatable plural label --- config/resource-lock.php | 1 + src/Resources/ResourceLockResource.php | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/config/resource-lock.php b/config/resource-lock.php index 097c90a..b7ae009 100644 --- a/config/resource-lock.php +++ b/config/resource-lock.php @@ -63,6 +63,7 @@ 'manager' => [ 'navigation_badge' => false, 'navigation_label' => 'Resource Lock Manager', + 'plural_label' => 'Resource Locks', 'navigation_group' => 'Settings', 'navigation_sort' => 1, 'limited_access' => false, diff --git a/src/Resources/ResourceLockResource.php b/src/Resources/ResourceLockResource.php index 6b6171f..040b8ec 100644 --- a/src/Resources/ResourceLockResource.php +++ b/src/Resources/ResourceLockResource.php @@ -17,7 +17,12 @@ class ResourceLockResource extends Resource public static function getModel(): string { - return config('resource-lock.models.ResourceLock', ResourceLock::class); + return __(config('resource-lock.models.ResourceLock', ResourceLock::class)); + } + + public static function getPluralLabel(): string + { + return __(config('resource-lock.manager.plural_label', 'Resource Locks')); } public static function form(Form $form): Form @@ -32,13 +37,13 @@ public static function table(Table $table): Tables\Table { return $table ->columns([ - TextColumn::make('id')->label('Lock ID'), - TextColumn::make('user.id')->label('User ID'), - TextColumn::make('lockable.id')->label('Lockable ID'), - TextColumn::make('lockable_type'), - TextColumn::make('created_at'), - TextColumn::make('updated_at'), - TextColumn::make('updated_at')->label('Expired') + TextColumn::make('id')->label(__('Lock ID')), + TextColumn::make('user.id')->label(__('User ID')), + TextColumn::make('lockable.id')->label(__('Lockable ID')), + TextColumn::make('lockable_type')->label(__('Lockable type')), + TextColumn::make('created_at')->label(__('Created at')), + TextColumn::make('updated_at')->label(__('Updated at')), + TextColumn::make('updated_at')->label(__('Expired')) ->badge() ->color(static function ($record): string { if ($record->isExpired()) { From 173fbed069c399025bd26e57890e05df36b874b7 Mon Sep 17 00:00:00 2001 From: Dennis Elsinga Date: Mon, 18 Sep 2023 18:42:37 +0200 Subject: [PATCH 2/2] Removed translation wrapper from `getModel` --- src/Resources/ResourceLockResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/ResourceLockResource.php b/src/Resources/ResourceLockResource.php index 040b8ec..7cc7653 100644 --- a/src/Resources/ResourceLockResource.php +++ b/src/Resources/ResourceLockResource.php @@ -17,7 +17,7 @@ class ResourceLockResource extends Resource public static function getModel(): string { - return __(config('resource-lock.models.ResourceLock', ResourceLock::class)); + return config('resource-lock.models.ResourceLock', ResourceLock::class); } public static function getPluralLabel(): string