GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — datatables/src/Search.php at develop · ginkelsoft-development/datatables Expand file tree/ Copy pathSearch.phpMore file actions 52 lines (45 loc) · 1.27 KB / Copy pathSearch.phpFile metadata and controls52 lines (45 loc) · 1.27 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 <?php namespace Ginkelsoft\DataTables; use Illuminate\Database\Eloquent\Builder; /** * Class Search * * Handles search functionality for DataTables. */ class Search { /** * @var string|null * Stores the current search term. */ protected ?string $searchTerm = null; /** * Set the search term. * * @param string|null $search The search term to be applied. * @return self Returns the Search instance for method chaining. */ public function setSearch(?string $search): self { $this->searchTerm = $search; return $this; } /** * Apply the search term to the given query. * * @param Builder $query The Eloquent query builder instance. * @param array<string> $columns The columns to search in. * @return Builder Returns the modified query with the search applied. */ public function apply(Builder $query, array $columns): Builder { if (! empty($this->searchTerm)) { $query->where(function (Builder $q) use ($columns) { foreach ($columns as $column) { $q->orWhere($column['column'], 'like', "%{$this->searchTerm}%"); } }); } return $query; } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |