Resources

List, create, edit and view

A resource comes with its pages, with no page files to generate.

A resource gets list, create, edit and view pages from one class, with no page files.

To change one, extend ListRecords, CreateRecord, EditRecord or ViewRecord, and return it from getPages().

use Xelqun\Panels\Resources\Pages\CreateRecord;
use Xelqun\Panels\Resources\Pages\EditRecord;
use Xelqun\Panels\Resources\Pages\ListRecords;
use Xelqun\Panels\Resources\Pages\ViewRecord;

public static function getPages(): array
{
    return [
        'index' => ListRecords::class,
        'create' => CreateRecord::class,
        'edit' => EditRecord::class,
        'view' => ViewRecord::class,
    ];
}
The create page of a resourceThe create page of a resource

Leave a key out to remove that page.

Header actions

getHeaderActions() adds buttons above the list.

use Xelqun\Panels\Actions\ExportAction;
use Xelqun\Panels\Actions\ImportAction;

public static function getHeaderActions(): array
{
    return [ExportAction::for(static::class), ImportAction::for(static::class)];
}

getUrl() builds a link to a page.

ProductResource::getUrl();
ProductResource::getUrl('view', ['record' => $product]);

Tabs across a record

getRecordSubNavigation() on a resource adds tabs across a record's pages.

See them in the demo.