You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,8 @@ abstract class Resource extends NovaResource
24
24
## Usage
25
25
26
26
Simply add `public static $searchRelations` array to any of your Nova resources.
27
-
This array has a relationship name as a key and an array of columns to search for as a value.
27
+
This array accepts a relationship name as a key and an array of searchable columns as a value.
28
+
28
29
```php
29
30
/**
30
31
* The relationship columns that should be searched.
@@ -38,39 +39,41 @@ public static $searchRelations = [
38
39
39
40
## Global search
40
41
41
-
You may disable global search for relationship columns by defining `$searchRelationsGlobally` property in your nova resource:
42
+
You may customize the rules of your searchable relationships in global search by defining the `$globalSearchRelations` property.
42
43
43
44
```php
44
45
/**
45
-
* Determine if relations should be searched globally.
46
+
* The relationship columns that should be searched globally.
46
47
*
47
48
* @var array
48
49
*/
49
-
public static $searchRelationsGlobally = false;
50
+
public static $globalSearchRelations = [
51
+
'user' => ['email'],
52
+
];
50
53
```
51
54
52
-
When you have disabled global search for relationships, you may still enable it for specific relationships like this:
55
+
You may disable the global search for relationships by defining the `$globalSearchRelations` property with an empty array.
56
+
53
57
```php
54
58
/**
55
-
* Determine if relations should be searched globally.
59
+
* The relationship columns that should be searched globally.
56
60
*
57
61
* @var array
58
62
*/
59
-
public static $searchRelationsGlobally = false;
63
+
public static $globalSearchRelations = [];
64
+
```
65
+
66
+
Alternatevily, you may disable the global search for relationships by setting the `$searchRelationsGlobally` property to `false`.
60
67
68
+
```php
61
69
/**
62
-
* The relationship columns that should be searched globally.
70
+
* Determine if relations should be searched globally.
63
71
*
64
72
* @var array
65
73
*/
66
-
public static $globalSearchRelations = [
67
-
'user' => ['email'],
68
-
];
69
-
74
+
public static $searchRelationsGlobally = false;
70
75
```
71
76
72
-
Now when searching globally, Laravel Nova is going to **ignore** relationships declared in `$searchRelations` and is going to use `$globalSearchRelations` instead.
73
-
74
77
## Nested relationships
75
78
76
79
You may search nested relationships using dot notation.
0 commit comments