4
4
5
5
namespace MoonShine \Laravel \Resources ;
6
6
7
+ use Closure ;
8
+ use Illuminate \Support \Collection ;
7
9
use MoonShine \Contracts \Core \CrudPageContract ;
8
10
use MoonShine \Contracts \Core \CrudResourceContract ;
9
11
use MoonShine \Contracts \Core \DependencyInjection \FieldsContract ;
12
14
use MoonShine \Contracts \Core \TypeCasts \DataWrapperContract ;
13
15
use MoonShine \Core \Resources \Resource ;
14
16
use MoonShine \Core \TypeCasts \MixedDataCaster ;
17
+ use MoonShine \Laravel \Components \Fragment ;
15
18
use MoonShine \Laravel \Pages \Crud \DetailPage ;
16
19
use MoonShine \Laravel \Pages \Crud \FormPage ;
17
20
use MoonShine \Laravel \Pages \Crud \IndexPage ;
@@ -250,7 +253,22 @@ protected function metrics(): array
250
253
*/
251
254
public function getMetrics (): array
252
255
{
253
- return $ this ->metrics ();
256
+ return Collection::make ($ this ->metrics ())
257
+ ->ensure (Metric::class)
258
+ ->toArray ();
259
+ }
260
+
261
+ /**
262
+ * @return ?Closure(array $components): Fragment
263
+ */
264
+ protected function fragmentMetrics (): ?Closure
265
+ {
266
+ return null ;
267
+ }
268
+
269
+ public function getFragmentMetrics (): ?Closure
270
+ {
271
+ return $ this ->fragmentMetrics ();
254
272
}
255
273
256
274
/**
@@ -279,7 +297,7 @@ public function getListComponentName(): string
279
297
return rescue (
280
298
fn (): string => $ this ->getIndexPage ()?->getListComponentName(),
281
299
"index-table- {$ this ->getUriKey ()}" ,
282
- false
300
+ false ,
283
301
);
284
302
}
285
303
@@ -295,7 +313,7 @@ public function getListEventName(?string $name = null, array $params = []): stri
295
313
return rescue (
296
314
fn (): string => AlpineJs::event ($ this ->getIndexPage ()?->getListEventName() ?? '' , $ name , $ params ),
297
315
AlpineJs::event (JsEvent::TABLE_UPDATED , $ name , $ params ),
298
- false
316
+ false ,
299
317
);
300
318
}
301
319
0 commit comments