Skip to content

Commit c1b769b

Browse files
committed
Update readme.
1 parent 7448528 commit c1b769b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,68 +55,68 @@ You can define metric links using the `route` method from the `Linkable` trait i
5555
**Index Route**
5656

5757
```php
58-
// NovaServiceProvider.php
58+
// App\Nova\Dashboards\Main.php
5959

6060
/**
61-
* Get the cards that should be displayed on the Nova dashboard.
61+
* Get the cards for the dashboard.
6262
*
6363
* @return array
6464
*/
6565
protected function cards()
6666
{
6767
return [
68-
(new JobsInProgress)->width('1/3')->route('index', ['resourceName' => 'jobs']),
68+
(new TotalUsers)->width('1/3')->route('nova.pages.index', ['resource' => 'users']),
6969
];
7070
}
7171
```
7272

7373
**OR using a Lens Route**
7474

7575
```php
76-
// NovaServiceProvider.php
76+
// App\Nova\Dashboards\Main.php
7777

7878
/**
79-
* Get the cards that should be displayed on the Nova dashboard.
79+
* Get the cards for the dashboard.
8080
*
8181
* @return array
8282
*/
8383
protected function cards()
8484
{
8585
return [
86-
(new JobsInProgress)->width('1/3')->route('lens', ['resourceName' => 'jobs', 'lens' => 'all-jobs']),
86+
(new TotalUsers)->width('1/3')->route('nova.pages.lens', ['resource' => 'users', 'lens' => 'active-users']),
8787
];
8888
}
8989
```
9090

9191
**OR using a Filter Route**
9292

9393
```php
94-
// NovaServiceProvider.php
94+
// App\Nova\Dashboards\Main.php
9595

9696
/**
97-
* Get the cards that should be displayed on the Nova dashboard.
97+
* Get the cards for the dashboard.
9898
*
9999
* @return array
100100
*/
101101
protected function cards()
102102
{
103-
$filters = base64_encode(json_encode([
103+
$filter = base64_encode(json_encode([
104104
[
105-
'class' => JobStatus::class,
105+
'class' => UserStatus::class,
106106
'value' => 'active',
107107
],
108108
]));
109109

110110
return [
111-
(new JobsInProgress)->width('1/3')->route('lens', ['resourceName' => 'jobs'], ['jobs_filter' => $filters]),
111+
(new JobsInProgress)->width('1/3')->route('nova.pages.index', ['resource' => 'users', 'users_filter' => $filter]),
112112
];
113113
}
114114
```
115115

116116
2. Or, within the card itself (useful for cards only available on detail screens where you might want to filter the url based on the current resource):
117117

118118
```php
119-
// In your linktable Nova metric class
119+
// In your linkable Nova metric class
120120

121121
/**
122122
* Calculate the value of the metric.
@@ -127,14 +127,14 @@ You can define metric links using the `route` method from the `Linkable` trait i
127127
public function calculate(Request $request, UnitOfMeasure $unitOfMeasure)
128128
{
129129
$result = $this->result($unitOfMeasure->items()->count());
130-
$params = ['resourceName' => 'items'];
131-
$query = [
130+
$params = [
131+
'resource' => 'items',
132132
'viaResource' => $request->resource,
133133
'viaResourceId' => $unitOfMeasure->id,
134134
'viaRelationship' => 'items',
135135
'relationshipType' => 'hasMany',
136136
];
137-
return $result->route('index', $params, $query);
137+
return $result->route('nova.pages.index', $params);
138138
}
139139
```
140140

0 commit comments

Comments
 (0)