| 1 | <?php |
||
| 8 | trait HasSearchBar |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var string |
||
| 12 | */ |
||
| 13 | public static $searchKey = '__search__'; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var array|string|\Closure |
||
| 17 | */ |
||
| 18 | protected $search; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param array|string|\Closure |
||
| 22 | * @return $this |
||
| 23 | */ |
||
| 24 | public function search($search) |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Apply the search query to the query. |
||
| 43 | * |
||
| 44 | * @param string $query |
||
| 45 | * @return mixed |
||
| 46 | */ |
||
| 47 | protected function applySearch($query = '') |
||
| 69 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: