2022-06-27 01:39:01 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Filament\Resources\System;
|
|
|
|
|
|
2022-06-29 17:00:15 +08:00
|
|
|
use App\Filament\OptionsTrait;
|
2022-06-27 01:39:01 +08:00
|
|
|
use App\Filament\Resources\System\SettingResource\Pages;
|
|
|
|
|
use App\Filament\Resources\System\SettingResource\RelationManagers;
|
|
|
|
|
use App\Models\Setting;
|
|
|
|
|
use Filament\Forms;
|
|
|
|
|
use Filament\Resources\Form;
|
|
|
|
|
use Filament\Resources\Resource;
|
|
|
|
|
use Filament\Resources\Table;
|
|
|
|
|
use Filament\Tables;
|
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
|
|
|
|
|
|
|
|
class SettingResource extends Resource
|
|
|
|
|
{
|
2022-06-29 17:00:15 +08:00
|
|
|
use OptionsTrait;
|
2022-06-27 01:39:01 +08:00
|
|
|
|
|
|
|
|
protected static ?string $model = Setting::class;
|
|
|
|
|
|
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-cog';
|
|
|
|
|
|
|
|
|
|
protected static ?string $navigationGroup = 'System';
|
|
|
|
|
|
2022-06-29 17:00:15 +08:00
|
|
|
protected static bool $shouldRegisterNavigation = true;
|
2022-06-27 13:22:16 +08:00
|
|
|
|
2022-06-27 01:39:01 +08:00
|
|
|
protected static function getNavigationLabel(): string
|
|
|
|
|
{
|
|
|
|
|
return __('admin.sidebar.settings');
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-29 17:00:15 +08:00
|
|
|
public static function getBreadcrumb(): string
|
|
|
|
|
{
|
|
|
|
|
return self::getNavigationLabel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-06-27 01:39:01 +08:00
|
|
|
public static function form(Form $form): Form
|
|
|
|
|
{
|
|
|
|
|
return $form
|
|
|
|
|
->schema([
|
|
|
|
|
Forms\Components\TextInput::make('name')->required()->disabled()->columnSpan(['sm' => 2]),
|
|
|
|
|
Forms\Components\Textarea::make('value')->required()->columnSpan(['sm' => 2])
|
|
|
|
|
->afterStateHydrated(function (Forms\Components\Textarea $component, $state) {
|
|
|
|
|
$arr = json_decode($state, true);
|
|
|
|
|
if (is_array($arr)) {
|
|
|
|
|
$component->disabled();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function table(Table $table): Table
|
|
|
|
|
{
|
|
|
|
|
return $table
|
|
|
|
|
->columns([
|
|
|
|
|
Tables\Columns\TextColumn::make('id'),
|
|
|
|
|
Tables\Columns\TextColumn::make('name')->searchable(),
|
|
|
|
|
Tables\Columns\TextColumn::make('value')->limit(),
|
|
|
|
|
Tables\Columns\BadgeColumn::make('autoload')->colors(['success' => 'yes', 'warning' => 'no']),
|
|
|
|
|
Tables\Columns\TextColumn::make('updated_at'),
|
|
|
|
|
])
|
|
|
|
|
->filters([
|
|
|
|
|
Tables\Filters\SelectFilter::make('autoload')->options(self::$yesOrNo),
|
|
|
|
|
])
|
|
|
|
|
->actions([
|
|
|
|
|
Tables\Actions\EditAction::make(),
|
|
|
|
|
])
|
|
|
|
|
->bulkActions([
|
|
|
|
|
// Tables\Actions\DeleteBulkAction::make(),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getRelations(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
//
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getPages(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2022-06-29 17:00:15 +08:00
|
|
|
// 'index' => Pages\ListSettings::route('/'),
|
2022-06-27 01:39:01 +08:00
|
|
|
// 'create' => Pages\CreateSetting::route('/create'),
|
2022-06-29 17:00:15 +08:00
|
|
|
'index' => Pages\EditSetting::route('/'),
|
2022-06-27 01:39:01 +08:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|