Skip to content

Commit

Permalink
Merge pull request #245 from lara-zeus/improve-toggle
Browse files Browse the repository at this point in the history
improve toggle in Entries Report
  • Loading branch information
atmonshi authored Jan 20, 2024
2 parents 5661572 + de44f30 commit 97ca113
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 24 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"flowframe/laravel-trend": "^0.1.5",
"guava/filament-icon-picker": "^2.0",
"lara-zeus/accordion": "^1.0",
"lara-zeus/core": "^3.0",
"lara-zeus/core": "^3.1",
"ryangjchandler/blade-tabler-icons": "^2.2"
},
"require-dev": {
Expand Down
47 changes: 24 additions & 23 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/Fields/Classes/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Hidden;
use Filament\Tables\Columns\Column;
use Filament\Tables\Columns\IconColumn;
use Guava\FilamentIconPicker\Forms\IconPicker;
use Illuminate\Database\Eloquent\Builder;
use LaraZeus\Accordion\Forms\Accordion;
use LaraZeus\Accordion\Forms\Accordions;
use LaraZeus\Bolt\Fields\FieldsContract;
use LaraZeus\Bolt\Models\Field;
use LaraZeus\Bolt\Models\Response;

class Toggle extends FieldsContract
{
Expand Down Expand Up @@ -96,4 +101,19 @@ public function appendFilamentComponentsOptions($component, $zeusField, bool $ha

return $component->live();
}

public function TableColumn(Field $field): ?Column
{
return IconColumn::make('zeusData.' . $field->id)
->label($field->name)
->boolean()
->searchable(query: function (Builder $query, string $search): Builder {
return $query
->whereHas('fieldsResponses', function ($query) use ($search) {
$query->where('response', 'like', '%' . $search . '%');
});
})
->getStateUsing(fn (Response $record) => $this->getFieldResponseValue($record, $field))
->toggleable();
}
}

0 comments on commit 97ca113

Please sign in to comment.