-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cf3612
commit 179a976
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# nova-searchable-belongs-to-filter | ||
A searchable Nova filter for belongsTo relationships. | ||
|
||
### Demo | ||
|
||
![demo](https://user-images.githubusercontent.com/4764281/69803436-76184200-11dc-11ea-9c19-4eacf1ba3b4c.gif) | ||
|
||
### Prerequisites | ||
|
||
This package assumes you have a text-search setup for your Eloquent models. See [Laravel Scout](https://laravel.com/docs/master/scout). | ||
|
||
### Installation | ||
|
||
todo: | ||
- [ ] add to packagist | ||
|
||
### Usage | ||
|
||
For this example let's assume a user belongs to a department and a department has many users. | ||
To make the relationship searchable via a filter, add this to the `filters()` function of your Nova user resource: | ||
|
||
```php | ||
// app/Nova/User.php | ||
public function filters(Request $request) | ||
{ | ||
return [ | ||
(new NovaSearchableBelongsToFilter) | ||
->fieldAttribute('department') | ||
->filterBy('department_id') | ||
]; | ||
} | ||
``` |