diff --git a/src/Filament/Clusters/System/Resources/CompanyResource.php b/src/Filament/Clusters/System/Resources/CompanyResource.php index 66c44a6..705ae73 100644 --- a/src/Filament/Clusters/System/Resources/CompanyResource.php +++ b/src/Filament/Clusters/System/Resources/CompanyResource.php @@ -23,6 +23,8 @@ class CompanyResource extends ChaosResource protected static ?string $model = Company::class; + protected static bool $isScopedToTenant = false; + protected static ?int $navigationSort = 1; public static function form(Form $form): Form @@ -52,6 +54,7 @@ public static function form(Form $form): Form public static function table(Table $table): Table { + // todo who can see what (check for roles) return ChaosTables::make( static::class, $table, diff --git a/src/Filament/Clusters/System/Resources/TagResource.php b/src/Filament/Clusters/System/Resources/TagResource.php index 3969a79..bc47cb0 100644 --- a/src/Filament/Clusters/System/Resources/TagResource.php +++ b/src/Filament/Clusters/System/Resources/TagResource.php @@ -5,12 +5,10 @@ use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; use Filament\Forms\Form; -use Filament\Forms\Set; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Str; use LaraZeus\Chaos\Filament\ChaosResource; use LaraZeus\Chaos\Forms\Components\MultiLang; use LaraZeus\Tartarus\Filament\Clusters\System; @@ -40,17 +38,14 @@ public static function form(Form $form): Form MultiLang::make('name') ->required() ->maxLength(255) - ->label(__(static::langFile() . '.name')) - ->live(onBlur: true) - ->afterStateUpdated(function (Set $set, $state) { - $set('slug.' . app()->getLocale(), Str::slug($state[app()->getLocale()])); - }), - MultiLang::make('slug') + ->label(__(static::langFile() . '.name')), + /*MultiLang::make('slug') ->live(onBlur: true) + ->hidden() ->label(__(static::langFile() . '.slug')) ->unique(ignorable: fn (?Model $record): ?Model => $record) ->required() - ->maxLength(255), + ->maxLength(255),*/ Select::make('type') ->label(__(static::langFile() . '.type')) ->columnSpan(2) diff --git a/src/Filament/Clusters/System/Resources/TagResource/Pages/CreateTag.php b/src/Filament/Clusters/System/Resources/TagResource/Pages/CreateTag.php index 4bad124..f531268 100644 --- a/src/Filament/Clusters/System/Resources/TagResource/Pages/CreateTag.php +++ b/src/Filament/Clusters/System/Resources/TagResource/Pages/CreateTag.php @@ -8,4 +8,15 @@ class CreateTag extends ChaosCreateRecord { protected static string $resource = TagResource::class; + + protected function mutateFormDataBeforeCreate(array $data): array + { + $data['slug'] = json_encode( + [ + app()->getLocale() => str($data['name'][app()->getLocale()])->slug()->toString(), + ] + ); + + return $data; + } } diff --git a/src/Filament/Clusters/System/Resources/TagResource/Pages/EditTag.php b/src/Filament/Clusters/System/Resources/TagResource/Pages/EditTag.php index 47e8e29..cd18bd8 100644 --- a/src/Filament/Clusters/System/Resources/TagResource/Pages/EditTag.php +++ b/src/Filament/Clusters/System/Resources/TagResource/Pages/EditTag.php @@ -8,4 +8,11 @@ class EditTag extends ChaosEditRecord { protected static string $resource = TagResource::class; + + protected function mutateFormDataBeforeSave(array $data): array + { + $data['slug'] = []; + + return $data; + } } diff --git a/src/Models/Company.php b/src/Models/Company.php index db22412..863d4ff 100644 --- a/src/Models/Company.php +++ b/src/Models/Company.php @@ -135,7 +135,7 @@ protected function defaultProfilePhotoUrl(): string })->join(' ')); $bgColor = 'BFA577'; - if (tenant()->primary_color !== null) { + if (tenant()?->primary_color !== null) { $colorName = str(tenant()->primary_color)->title(); $color = constant("Filament\Support\Colors\Color::$colorName"); $bgColor = str(Rgb::fromString('rgb(' . $color[500] . ')')->toHex())->replace('#', ''); diff --git a/src/Models/Tag.php b/src/Models/Tag.php index d2d3fb5..061e337 100644 --- a/src/Models/Tag.php +++ b/src/Models/Tag.php @@ -13,7 +13,7 @@ class Tag extends \Spatie\Tags\Tag use ForCompany; use SoftDeletes; - public function getCasts(): array + protected function casts(): array { return [ 'type' => TartarusPlugin::getModel('TagType'),