ListProducts.php
TLDR
This file is a PHP class located at app/Filament/Resources/Shop/ProductResource/Pages/ListProducts.php
. It extends the ListRecords
class and provides additional functionality for listing products.
Classes
ListProducts
This class extends the ListRecords
class and provides functionality for listing products. It uses the ExposesTableToWidgets
trait to expose the table to widgets. It has the following methods:
-
getActions()
: Returns an array of actions to be displayed for the list of products. In this case, it returns a singleCreateAction
. -
getHeaderWidgets()
: Returns an array of widgets to be displayed in the header of the list of products. In this case, it returns the widgets defined in theProductResource
class.
<?php
namespace App\Filament\Resources\Shop\ProductResource\Pages;
use App\Filament\Resources\Shop\ProductResource;
use Filament\Actions;
use Filament\Pages\Concerns\ExposesTableToWidgets;
use Filament\Resources\Pages\ListRecords;
class ListProducts extends ListRecords
{
use ExposesTableToWidgets;
protected static string $resource = ProductResource::class;
protected function getActions(): array
{
return [
Actions\CreateAction::make(),
];
}
protected function getHeaderWidgets(): array
{
return ProductResource::getWidgets();
}
}