From dafd64c0702ed80909e69ac8a5268d4e07ea7522 Mon Sep 17 00:00:00 2001 From: lam0819 Date: Thu, 17 Oct 2024 16:34:32 +0000 Subject: [PATCH] Fix styling --- src/Components/PanOverview.php | 78 +++++++++++++-------------- src/FilamentPanphpServiceProvider.php | 4 +- src/Models/PanAnalytics.php | 6 ++- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/src/Components/PanOverview.php b/src/Components/PanOverview.php index c20cddc..1c929ad 100644 --- a/src/Components/PanOverview.php +++ b/src/Components/PanOverview.php @@ -2,17 +2,16 @@ namespace SolutionForest\FilamentPanphp\Components; -use Filament\Forms\Get; -use Filament\Tables\Table; -use Filament\Tables\Columns\TextColumn; -use Filament\Forms\Components\TextInput; -use Filament\Forms\Components\TagsInput; use Filament\Forms\Components\Checkbox; -use Filament\Widgets\TableWidget as BaseWidget; +use Filament\Forms\Components\TagsInput; +use Filament\Forms\Components\TextInput; +use Filament\Forms\Get; use Filament\Tables\Actions\Action; use Filament\Tables\Actions\CreateAction; use Filament\Tables\Actions\DeleteAction; -use Filament\Tables\Actions\ForceDeleteAction; +use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Table; +use Filament\Widgets\TableWidget as BaseWidget; use Pan\PanConfiguration; use SolutionForest\FilamentPanphp\Models\PanAnalytics; @@ -21,48 +20,49 @@ class PanOverview extends BaseWidget public function table(Table $table): Table { $currentPanConfiguration = PanConfiguration::instance()->toArray(); - return $table->query(fn() => PanAnalytics::query()) + + return $table->query(fn () => PanAnalytics::query()) ->columns([ TextColumn::make('name')->searchable(), TextColumn::make('impressions')->sortable(), TextColumn::make('hovers')->sortable(), - TextColumn::make('clicks')->sortable() + TextColumn::make('clicks')->sortable(), ]) ->actions([ - DeleteAction::make() + DeleteAction::make(), ]) ->headerActions([ CreateAction::make() - ->disableLabel() - ->icon('heroicon-o-plus-circle') - ->model(PanAnalytics::class) - ->form([ - TextInput::make('name') - ->required() - ->unique('pan_analytics', 'name') - ->maxLength(255), - ]), + ->disableLabel() + ->icon('heroicon-o-plus-circle') + ->model(PanAnalytics::class) + ->form([ + TextInput::make('name') + ->required() + ->unique('pan_analytics', 'name') + ->maxLength(255), + ]), Action::make('Config') - ->disableLabel() - ->icon('heroicon-o-adjustments-horizontal') - ->form([ - Checkbox::make('unlimitedAnalytics') - ->inline() - ->live() - ->default($currentPanConfiguration['max_analytics'] >= PHP_INT_MAX) - ->hidden(fn (Get $get): bool => $currentPanConfiguration['max_analytics'] < PHP_INT_MAX), - TextInput::make('maxAnalytics') - ->numeric() - ->label('Max Analytics') - ->default($currentPanConfiguration['max_analytics']) - ->visible(fn (Get $get): bool => ! $get('unlimitedAnalytics')), - TagsInput::make('allowedAnalytics') - ->label('Allowed Analytics') - ->separator(',') - ->default($currentPanConfiguration['allowed_analytics']) - ]) - ->modalCancelAction(false) - ->modalSubmitAction(false) + ->disableLabel() + ->icon('heroicon-o-adjustments-horizontal') + ->form([ + Checkbox::make('unlimitedAnalytics') + ->inline() + ->live() + ->default($currentPanConfiguration['max_analytics'] >= PHP_INT_MAX) + ->hidden(fn (Get $get): bool => $currentPanConfiguration['max_analytics'] < PHP_INT_MAX), + TextInput::make('maxAnalytics') + ->numeric() + ->label('Max Analytics') + ->default($currentPanConfiguration['max_analytics']) + ->visible(fn (Get $get): bool => ! $get('unlimitedAnalytics')), + TagsInput::make('allowedAnalytics') + ->label('Allowed Analytics') + ->separator(',') + ->default($currentPanConfiguration['allowed_analytics']), + ]) + ->modalCancelAction(false) + ->modalSubmitAction(false), // ->action(function (array $data): void { // $unlimitedAnalytics = $data['unlimitedAnalytics'] ?? false; // $maxAnalytics = $data['maxAnalytics'] ?? 50; diff --git a/src/FilamentPanphpServiceProvider.php b/src/FilamentPanphpServiceProvider.php index 47e7bf3..0e2587e 100644 --- a/src/FilamentPanphpServiceProvider.php +++ b/src/FilamentPanphpServiceProvider.php @@ -10,11 +10,11 @@ use Filament\Support\Facades\FilamentIcon; use Illuminate\Filesystem\Filesystem; use Livewire\Features\SupportTesting\Testable; +use SolutionForest\FilamentPanphp\Commands\FilamentPanphpCommand; +use SolutionForest\FilamentPanphp\Testing\TestsFilamentPanphp; use Spatie\LaravelPackageTools\Commands\InstallCommand; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; -use SolutionForest\FilamentPanphp\Commands\FilamentPanphpCommand; -use SolutionForest\FilamentPanphp\Testing\TestsFilamentPanphp; class FilamentPanphpServiceProvider extends PackageServiceProvider { diff --git a/src/Models/PanAnalytics.php b/src/Models/PanAnalytics.php index 910ba4e..2ba89c2 100644 --- a/src/Models/PanAnalytics.php +++ b/src/Models/PanAnalytics.php @@ -9,8 +9,9 @@ class PanAnalytics extends Model { use HasFactory; - + protected $table = 'pan_analytics'; + protected $fillable = [ 'name', 'impressions', @@ -19,6 +20,7 @@ class PanAnalytics extends Model ]; public $timestamps = false; + public $rules = [ 'name' => 'required|unique:pan_analytics|max:255', ]; @@ -31,4 +33,4 @@ public static function boot() Validator::make($model->toArray(), $model->rules)->validate(); }); } -} \ No newline at end of file +}