diff --git a/composer.json b/composer.json index cacdd56..ba9f946 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,10 @@ "filament/spatie-laravel-media-library-plugin": "^3.0@beta", "filament/spatie-laravel-tags-plugin": "^3.0@beta", "spatie/laravel-medialibrary": "^10.0.0", + "awcodes/filament-tiptap-editor": "^3.0", "spatie/laravel-sluggable": "^3.3", "spatie/laravel-tags": "^4.4", + "andrewdwallo/filament-selectify": "^2.0", "lara-zeus/core": "^3.0" }, "require-dev": { diff --git a/src/Filament/Resources/FaqResource.php b/src/Filament/Resources/FaqResource.php index e04056c..5ef46b6 100644 --- a/src/Filament/Resources/FaqResource.php +++ b/src/Filament/Resources/FaqResource.php @@ -3,6 +3,7 @@ namespace LaraZeus\Sky\Filament\Resources; use Filament\Forms\Components\RichEditor; +use Filament\Forms\Components\Section; use Filament\Forms\Components\SpatieTagsInput; use Filament\Forms\Components\Textarea; use Filament\Forms\Form; @@ -46,21 +47,25 @@ public static function form(Form $form): Form { return $form ->schema([ - Textarea::make('question') - ->label(__('Question')) - ->required() - ->maxLength(65535) - ->columnSpan(2), + Section::make(__('Library File')) + ->columns(2) + ->schema([ + Textarea::make('question') + ->label(__('Question')) + ->required() + ->maxLength(65535) + ->columnSpan(2), - RichEditor::make('answer') - ->label(__('Answer')) - ->required() - ->maxLength(65535) - ->columnSpan(2), + RichEditor::make('answer') + ->label(__('Answer')) + ->required() + ->maxLength(65535) + ->columnSpan(2), - SpatieTagsInput::make('category') - ->type('faq') - ->label(__('FAQ Categories')), + SpatieTagsInput::make('category') + ->type('faq') + ->label(__('FAQ Categories')), + ]), ]); } diff --git a/src/Filament/Resources/LibraryResource.php b/src/Filament/Resources/LibraryResource.php index ca26c79..4dc0434 100644 --- a/src/Filament/Resources/LibraryResource.php +++ b/src/Filament/Resources/LibraryResource.php @@ -2,7 +2,6 @@ namespace LaraZeus\Sky\Filament\Resources; -use Filament\Forms\Components\Radio; use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; use Filament\Forms\Components\SpatieMediaLibraryFileUpload; @@ -24,6 +23,7 @@ use LaraZeus\Sky\Filament\Resources\LibraryResource\Pages; use LaraZeus\Sky\Models\Library; use LaraZeus\Sky\SkyPlugin; +use Wallo\FilamentSelectify\Components\ButtonGroup; class LibraryResource extends SkyResource { @@ -42,56 +42,59 @@ public static function form(Form $form): Form { return $form ->schema([ - TextInput::make('title') - ->label(__('Library Title')) - ->required() - ->maxLength(255) - ->live(onBlur: true) - ->afterStateUpdated(function (Set $set, $state, $context) { - if ($context === 'edit') { - return; - } - - $set('slug', Str::slug($state)); - }), - - TextInput::make('slug') - ->unique(ignorable: fn (?Library $record): ?Library => $record) - ->required() - ->maxLength(255) - ->label(__('Library Slug')), - - Textarea::make('description') - ->maxLength(255) - ->label(__('Library Description')) - ->columnSpan(2), - - SpatieTagsInput::make('category') - ->type('library') - ->label(__('Library Categories')), - - Select::make('type') - ->label(__('Library Type')) - ->visible(SkyPlugin::get()->getLibraryTypes() !== null) - ->options(SkyPlugin::get()->getLibraryTypes()), + Section::make(__('Library File')) + ->columns(2) + ->schema([ + TextInput::make('title') + ->label(__('Library Title')) + ->required() + ->maxLength(255) + ->live(onBlur: true) + ->afterStateUpdated(function (Set $set, $state, $context) { + if ($context === 'edit') { + return; + } + + $set('slug', Str::slug($state)); + }), + + TextInput::make('slug') + ->unique(ignorable: fn (?Library $record): ?Library => $record) + ->required() + ->maxLength(255) + ->label(__('Library Slug')), + + Textarea::make('description') + ->maxLength(255) + ->label(__('Library Description')) + ->columnSpan(2), + + SpatieTagsInput::make('category') + ->type('library') + ->label(__('Library Categories')), + + Select::make('type') + ->label(__('Library Type')) + ->visible(SkyPlugin::get()->getLibraryTypes() !== null) + ->options(SkyPlugin::get()->getLibraryTypes()), + ]), Section::make(__('Library File')) + ->collapsible() + ->compact() ->schema([ - Radio::make('upload_or_url') - ->label('') + ButtonGroup::make('upload_or_url') ->live() ->dehydrated(false) ->afterStateHydrated(function (Set $set, Get $get) { $setVal = ($get('file_path') === null) ? 'upload' : 'url'; $set('upload_or_url', $setVal); }) - ->default('upload') ->options([ 'upload' => __('upload'), 'url' => __('url'), ]) - ->inline(), - + ->default('upload'), SpatieMediaLibraryFileUpload::make('file_path_upload') ->collection('library') ->multiple() @@ -103,8 +106,7 @@ public static function form(Form $form): Form ->label(__('file url')) ->visible(fn (Get $get) => $get('upload_or_url') === 'url') ->url(), - ]) - ->collapsible(), + ]), ]); } diff --git a/src/Filament/Resources/PageResource.php b/src/Filament/Resources/PageResource.php index ef8cbfe..58ae85e 100644 --- a/src/Filament/Resources/PageResource.php +++ b/src/Filament/Resources/PageResource.php @@ -5,7 +5,6 @@ use Filament\Forms\Components\DateTimePicker; use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Placeholder; -use Filament\Forms\Components\Radio; use Filament\Forms\Components\Select; use Filament\Forms\Components\SpatieMediaLibraryFileUpload; use Filament\Forms\Components\Tabs; @@ -34,6 +33,7 @@ use LaraZeus\Sky\Filament\Resources\PageResource\Pages; use LaraZeus\Sky\Models\Post; use LaraZeus\Sky\SkyPlugin; +use Wallo\FilamentSelectify\Components\ButtonGroup; class PageResource extends SkyResource { @@ -124,20 +124,19 @@ public static function form(Form $form): Form ]), Tabs\Tab::make(__('Image'))->schema([ Placeholder::make(__('Featured Image')), - Radio::make('featured_image_type') - ->label('') + ButtonGroup::make('featured_image_type') ->live() + ->label('') ->dehydrated(false) ->afterStateHydrated(function (Set $set, Get $get) { $setVal = ($get('featured_image') === null) ? 'upload' : 'url'; $set('featured_image_type', $setVal); }) - ->default('upload') ->options([ 'upload' => __('upload'), 'url' => __('url'), ]) - ->inline(), + ->default('upload'), SpatieMediaLibraryFileUpload::make('featured_image_upload') ->collection('pages') ->visible(fn (Get $get) => $get('featured_image_type') === 'upload') diff --git a/src/Filament/Resources/PostResource.php b/src/Filament/Resources/PostResource.php index 2017da8..fb1d162 100644 --- a/src/Filament/Resources/PostResource.php +++ b/src/Filament/Resources/PostResource.php @@ -5,7 +5,6 @@ use Filament\Forms\Components\DateTimePicker; use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Placeholder; -use Filament\Forms\Components\Radio; use Filament\Forms\Components\Select; use Filament\Forms\Components\SpatieMediaLibraryFileUpload; use Filament\Forms\Components\SpatieTagsInput; @@ -35,6 +34,7 @@ use LaraZeus\Sky\Filament\Resources\PostResource\Pages; use LaraZeus\Sky\Models\Post; use LaraZeus\Sky\SkyPlugin; +use Wallo\FilamentSelectify\Components\ButtonGroup; // @mixin Builder class PostResource extends SkyResource @@ -126,21 +126,19 @@ public static function form(Form $form): Form Tabs\Tab::make(__('Image'))->schema([ Placeholder::make(__('Featured Image')), - Radio::make('featured_image_type') - ->label('') + ButtonGroup::make('featured_image_type') ->live() + ->label('') ->dehydrated(false) ->afterStateHydrated(function (Set $set, Get $get) { $setVal = ($get('featured_image') === null) ? 'upload' : 'url'; $set('featured_image_type', $setVal); }) - ->default('upload') ->options([ 'upload' => __('upload'), 'url' => __('url'), ]) - ->inline(), - + ->default('upload'), SpatieMediaLibraryFileUpload::make('featured_image_upload') ->collection('posts') ->visible(fn (Get $get) => $get('featured_image_type') === 'upload') diff --git a/src/Filament/Resources/TagResource.php b/src/Filament/Resources/TagResource.php index f196ac1..094ec86 100644 --- a/src/Filament/Resources/TagResource.php +++ b/src/Filament/Resources/TagResource.php @@ -2,6 +2,7 @@ namespace LaraZeus\Sky\Filament\Resources; +use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; @@ -34,20 +35,25 @@ public static function form(Form $form): Form { return $form ->schema([ - TextInput::make('name') - ->required() - ->maxLength(255) - ->label(__('Tag.Name')) - ->live(onBlur: true) - ->afterStateUpdated(function (Set $set, $state) { - $set('slug', Str::slug($state)); - }), - TextInput::make('slug') - ->unique(ignorable: fn (?Model $record): ?Model => $record) - ->required() - ->maxLength(255), - Select::make('type') - ->options(SkyPlugin::get()->getTagTypes()), + Section::make() + ->columns(2) + ->schema([ + TextInput::make('name') + ->required() + ->maxLength(255) + ->label(__('Tag.Name')) + ->live(onBlur: true) + ->afterStateUpdated(function (Set $set, $state) { + $set('slug', Str::slug($state)); + }), + TextInput::make('slug') + ->unique(ignorable: fn (?Model $record): ?Model => $record) + ->required() + ->maxLength(255), + Select::make('type') + ->columnSpan(2) + ->options(SkyPlugin::get()->getTagTypes()), + ]), ]); }