Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
KaanTanis committed Nov 15, 2023
1 parent 6f55022 commit 3b8f301
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ FilamentTabTranslatable::make()
// IMPORTANT: Make sure field type is json in database
// The second parameter 'columnName' is only for translated columns. Not required if the column name is the same as the key.
```
### Render type
```php
->render(:contained: false) // default true
// More details: https://filamentphp.com/docs/3.x/infolists/layout/tabs#removing-the-styled-container
````

## Example

Expand Down
4 changes: 2 additions & 2 deletions config/filament-tab-translatable.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

return [
'default' => 'en', // for first tab
'default' => 'tr', // for first tab

'laravellocalization' => false, // if you use mcamara/laravel-localization package

'tab-type' => 'name', // code or name
'tab-type' => 'code', // code or name

'list' => [
'tr' => [
Expand Down
14 changes: 8 additions & 6 deletions src/FilamentTabTranslatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class FilamentTabTranslatable

protected ?array $untranslatableTabs = [];

public static function make()
public static function make(): FilamentTabTranslatable
{
return new self;
}

public function translatable(array $components, string $column = null)
public function translatable(array $components, string $column = null): static
{
$this->column = $column ? $column . '.' : $column;
$this->translatableTabs = $this->getTranslatableTabs($components);
Expand Down Expand Up @@ -63,8 +63,9 @@ protected function getTabName($language): string
};
}

public function untranslatable(array $components)
public function untranslatable(array $components, string $column = null): static
{
$this->column = $column ? $column . '.' : $column;
$this->untranslatableTabs = $this->getUntranslatableTabs($components);

return $this;
Expand All @@ -83,9 +84,9 @@ protected function makeUntranslatableTab($components)

foreach ($components as $item) {
$manipulatedItem = clone $item;
$manipulatedItem->name($item->getName())
$manipulatedItem->name($this->column . $item->getName())
->label($item->getLabel())
->statePath($item->getName());
->statePath($this->column . $item->getName());

$manipulatedComponents[] = $manipulatedItem;
}
Expand All @@ -96,9 +97,10 @@ protected function makeUntranslatableTab($components)
->schema($manipulatedComponents);
}

public function render(): Tabs
public function render($contained = true): Tabs
{
return Tabs::make('tabs')
->contained($contained)
->schema(array_merge($this->untranslatableTabs, $this->translatableTabs));
}
}

0 comments on commit 3b8f301

Please sign in to comment.