Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherfrontendguy authored Nov 28, 2019
1 parent 7cf3612 commit 179a976
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
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')
];
}
```

0 comments on commit 179a976

Please sign in to comment.