Files
nexusphp/app/Filament/Resources/Section/IconResource.php

127 lines
4.2 KiB
PHP
Raw Normal View History

2022-10-27 20:21:54 +08:00
<?php
namespace App\Filament\Resources\Section;
use Filament\Schemas\Schema;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Radio;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\Section\IconResource\Pages\ListIcons;
use App\Filament\Resources\Section\IconResource\Pages\CreateIcon;
use App\Filament\Resources\Section\IconResource\Pages\EditIcon;
2022-10-27 20:21:54 +08:00
use App\Filament\OptionsTrait;
2022-12-01 00:45:22 +08:00
use App\Filament\EditRedirectIndexTrait;
2022-10-27 20:21:54 +08:00
use App\Filament\Resources\Section\IconResource\Pages;
use App\Filament\Resources\Section\IconResource\RelationManagers;
use App\Models\Icon;
use Filament\Forms;
use Filament\Resources\Resource;
2024-12-25 23:09:07 +08:00
use Filament\Tables\Table;
2022-10-27 20:21:54 +08:00
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class IconResource extends Resource
{
use OptionsTrait;
protected static ?string $model = Icon::class;
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-ticket';
2022-10-27 20:21:54 +08:00
protected static string | \UnitEnum | null $navigationGroup = 'Section';
2022-10-27 20:21:54 +08:00
protected static ?int $navigationSort = 10;
2024-12-25 23:09:07 +08:00
public static function getNavigationLabel(): string
2022-10-27 20:21:54 +08:00
{
return __('admin.sidebar.icon');
}
public static function getBreadcrumb(): string
{
return self::getNavigationLabel();
}
public static function form(Schema $schema): Schema
2022-10-27 20:21:54 +08:00
{
return $schema
->components([
Textarea::make('tip')
2025-02-06 22:32:36 +08:00
->default(nexus_trans('label.icon.desc'))
->disabled()
->columnSpanFull()
->rows(18)
,
TextInput::make('name')
2022-10-27 20:21:54 +08:00
->label(__('label.name'))
->required()
,
TextInput::make('folder')
2022-10-27 20:21:54 +08:00
->label(__('label.icon.folder'))
->required()
->helperText(__('label.icon.folder_help'))
,
Radio::make('multilang')
2022-10-27 20:21:54 +08:00
->label(__('label.icon.multilang'))
->options(self::$yesOrNo)
->required()
->helperText(__('label.icon.multilang_help'))
,
Radio::make('secondicon')
2022-10-27 20:21:54 +08:00
->label(__('label.icon.secondicon'))
->options(self::$yesOrNo)
->required()
->helperText(__('label.icon.secondicon_help'))
,
TextInput::make('cssfile')->label(__('label.icon.cssfile'))->helperText(__('label.icon.cssfile_help')),
TextInput::make('designer')->label(__('label.icon.designer'))->helperText(__('label.icon.designer_help')),
Textarea::make('comment')->label(__('label.icon.comment'))->helperText(__('label.icon.comment_help')),
2022-10-27 20:21:54 +08:00
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id'),
TextColumn::make('name')->label(__('label.name')),
TextColumn::make('folder')->label(__('label.icon.folder')),
TextColumn::make('multilang')->label(__('label.icon.multilang')),
TextColumn::make('secondicon')->label(__('label.icon.secondicon')),
TextColumn::make('cssfile')->label(__('label.icon.cssfile')),
TextColumn::make('designer')->label(__('label.icon.designer')),
2022-10-27 20:21:54 +08:00
])
->filters([
//
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
2022-10-27 20:21:54 +08:00
])
->toolbarActions([
DeleteBulkAction::make(),
2022-10-27 20:21:54 +08:00
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListIcons::route('/'),
'create' => CreateIcon::route('/create'),
'edit' => EditIcon::route('/{record}/edit'),
2022-10-27 20:21:54 +08:00
];
}
}