83 lines
2.4 KiB
PHP
83 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\SettingResource\Pages;
|
|
use App\Filament\Resources\SettingResource\RelationManagers;
|
|
use App\Models\Setting;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Fieldset;
|
|
|
|
class SettingResource extends Resource
|
|
{
|
|
protected static ?string $model = Setting::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-cog';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\TextInput::make('key')
|
|
->label(__('Key'))
|
|
->required()
|
|
->maxLength(255)
|
|
->hiddenOn('edit'),
|
|
Forms\Components\Fieldset::make()
|
|
->label(fn (?Setting $record) => $record ? $record->key : __('New Setting'))
|
|
->schema([
|
|
TextInput::make('value')
|
|
->label(__('Value'))
|
|
->disableLabel()
|
|
])
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('key')->label(__('Key'))->searchable()->sortable(),
|
|
Tables\Columns\TextColumn::make('value')->label(__('Value'))->searchable()->sortable(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
])
|
|
->emptyStateActions([
|
|
Tables\Actions\CreateAction::make(),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListSettings::route('/'),
|
|
'create' => Pages\CreateSetting::route('/create'),
|
|
'edit' => Pages\EditSetting::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|