You've already forked Atomcms-edit
Initial commit
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionCategoryResource\Pages\CreateHelpQuestionCategory;
|
||||
use App\Filament\Resources\Atom\HelpQuestionCategoryResource\Pages\EditHelpQuestionCategory;
|
||||
use App\Filament\Resources\Atom\HelpQuestionCategoryResource\Pages\ListHelpQuestionCategories;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\Help\WebsiteHelpCenterCategory;
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class HelpQuestionCategoryResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $model = WebsiteHelpCenterCategory::class;
|
||||
|
||||
#[\Override]
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-folder';
|
||||
|
||||
#[\Override]
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Help Center';
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $slug = 'help/categories';
|
||||
|
||||
public static string $translateIdentifier = 'help-categories';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components(static::getForm());
|
||||
}
|
||||
|
||||
public static function getForm(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('name')
|
||||
->label(__('Name'))
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->helperText(__('Use :hotel for dynamic hotel name')),
|
||||
|
||||
Textarea::make('content')
|
||||
->label(__('Content'))
|
||||
->rows(8)
|
||||
->helperText(__('Use :hotel for dynamic hotel name. Use <br/> for line breaks.')),
|
||||
|
||||
TextInput::make('image_url')
|
||||
->label(__('Image URL'))
|
||||
->maxLength(255),
|
||||
|
||||
TextInput::make('button_text')
|
||||
->label(__('Button Text'))
|
||||
->maxLength(255),
|
||||
|
||||
TextInput::make('button_url')
|
||||
->label(__('Button URL'))
|
||||
->maxLength(255),
|
||||
|
||||
ColorPicker::make('button_color')
|
||||
->label(__('Button Color')),
|
||||
|
||||
ColorPicker::make('button_border_color')
|
||||
->label(__('Button Border Color')),
|
||||
|
||||
Toggle::make('small_box')
|
||||
->label(__('Small Box'))
|
||||
->helperText(__('Show as small box on the right side')),
|
||||
|
||||
TextInput::make('position')
|
||||
->label(__('Position'))
|
||||
->numeric()
|
||||
->default(0),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns(static::getTable());
|
||||
}
|
||||
|
||||
public static function getTable(): array
|
||||
{
|
||||
return [
|
||||
TextColumn::make('id')
|
||||
->label(__('ID'))
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('name')
|
||||
->label(__('Name'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('button_text')
|
||||
->label(__('Button Text')),
|
||||
|
||||
ToggleColumn::make('small_box')
|
||||
->label(__('Small Box')),
|
||||
|
||||
TextColumn::make('position')
|
||||
->label(__('Position'))
|
||||
->sortable(),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListHelpQuestionCategories::route('/'),
|
||||
'create' => CreateHelpQuestionCategory::route('/create'),
|
||||
'edit' => EditHelpQuestionCategory::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user