main

filamentphp/demo

Last updated at: 29/12/2023 09:44

ListCategories.php

TLDR

This file is a part of the Demo Projects project and it is located at app/Filament/Resources/Shop/CategoryResource/Pages/ListCategories.php. This file contains a class named ListCategories that extends the ListRecords class. It includes a method named getActions that returns an array of actions.

Classes

ListCategories

The ListCategories class is a subclass of the ListRecords class. It represents a page that lists categories in the shop. It has a static property named $resource which is set to CategoryResource::class.

Methods

getActions

This method returns an array of actions. It includes two actions:

  • ImportAction action with an importer of CategoryImporter class.
  • CreateAction action.
<?php

namespace App\Filament\Resources\Shop\CategoryResource\Pages;

use App\Filament\Imports\Shop\CategoryImporter;
use App\Filament\Resources\Shop\CategoryResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListCategories extends ListRecords
{
    protected static string $resource = CategoryResource::class;

    protected function getActions(): array
    {
        return [
            Actions\ImportAction::make()
                ->importer(CategoryImporter::class),
            Actions\CreateAction::make(),
        ];
    }
}