This is a form containing inputs with the signature of the search query string. Additionally, it generates custom build options. It's a separate component of the delegate class \App\Admin\Delegates\SearchForm
. The delegate also includes assistants like inDefault
for building ready-made tables.
use App\Admin\Delegates\SearchForm;
return $page->card(
$card->search_form(
$searchForm->id(),
...,
$searchForm->at(),
),
)
//OR
return $page->card(
$card->search_form(
$searchForm->inDefault(
...,
),
),
)
For convenient searching, a small set of inputs is supported. Each input inherits the functionality of form inputs and therefore works almost identically to them. However, there's a distinction: after the input name and its label, the third parameter indicates the type of comparison or the function that will process the builder.
When a property or method starts with in_[input method]_*
, a magical addition occurs, allowing you to specify a name in the model or property name, such as in_input_name
. If this is a method, then the first parameter will be the label setting, like so: ->in_input_name('Name of row', string|callable $condition)
.
=%
.=%
.=
.=
.>=
.=
.between
.between
.>=
.>=
.=
.FontAwesome
icon selection field. Default type: =%
.=
.=
.in
.in
.in
.=
.=
- Equal to input value!=
- Not equal to input value>=
- Greater than or equal to input value<=
- Less than or equal to input value>
- More input value<
- Less input value%=
- Search starts with input value=%
- The search term ends with the input value%=%
- Search may contain an input valuenull
- Lookup must be null
not_null
- Search must not be null
in
- Search must contain one of the optionsnot_in
- Search must not contain any of the optionsbetween
- The search must be between the input valuenot_between
- The search must not be between the input valueYou can define your own input behavior by passing a Closure instead of the comparison type:
$card->search_form(
$searchForm->input('name', 'Search by name', function ($builder, $value, $key) {
return $builder->where('name', 'like', '%' . $value . '%');
}),
)