Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/BoardResourcePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Filament\Actions\Exceptions\ActionNotResolvableException;
use Filament\Forms\Contracts\HasForms;
use Filament\Resources\Pages\Page;
use Livewire\Attributes\Url;
use Relaticle\Flowforge\Concerns\BaseBoard;
use Relaticle\Flowforge\Contracts\HasBoard;

Expand All @@ -25,6 +26,9 @@ abstract class BoardResourcePage extends Page implements HasActions, HasBoard, H
{
use BaseBoard;

#[Url(as: 'search')]
public $tableSearch = '';

protected string $view = 'flowforge::filament.pages.board-page';

/**
Expand Down
7 changes: 5 additions & 2 deletions src/Concerns/CanSearchBoardRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ trait CanSearchBoardRecords
/**
* Make the board searchable.
*/
public function searchable(array | Closure $fields = []): static
public function searchable(string | array | Closure $fields = []): static
{
$this->searchableFields = $this->evaluate($fields);
// Ensure fields is an array
$searchableFields = is_string($fields) ? [$fields] : $fields;

$this->searchableFields = $this->evaluate($searchableFields);
$this->isSearchable = true;

return $this;
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasBoardRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ public function getBoardRecords(string $columnId): Collection
$queryClone = (clone $baseQuery)->where($statusField, $columnId);
}

// Apply search
if ($livewire->hasTableSearch()) {
$queryClone->where(function ($q) use (&$livewire) {
return $q->whereAny($this->getSearchableFields(), 'LIKE', '%' . $livewire->getTableSearch() . '%');
});
}

$positionField = $this->getPositionIdentifierAttribute();

if ($positionField && $this->modelHasColumn($queryClone->getModel(), $positionField)) {
Expand Down