PHP code example of nckrtl / filament-resource-templates

1. Go to this page and download the library: Download nckrtl/filament-resource-templates library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nckrtl / filament-resource-templates example snippets


namespace App\Filament\Resources\PageResource\Pages\Default;

use App\Filament\Resources\PageResource\Pages\Partials\Sections\TextSectionData;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Components\Tabs\Tab;
use Filament\Forms\Components\TextInput;
use NckRtl\FilamentResourceTemplates\Template;

class DefaultTemplate extends Template
{
    const NAME = 'Default';

    public string $title;

    public string $slug;

    public static function form()
    {
        return Tabs::make('Label')
            ->tabs([
                Tab::make('General')
                    ->schema([
                        Grid::make(2)->schema([
                            TextInput::make('title')
                                ->placeholder('Titel')
                                ->label('Titel'),
                            TextInput::make('slug')
                                ->placeholder('slug')
                                ->prefix(config('app.url').'/')
                                ->label('slug'),
                        ]),
                    ]),
            ]);
    }
}

const SECTIONS = [
    TextSectionData::SECTION_KEY => TextSectionData::class,
];

namespace App\Filament\Resources\PageResource\Pages\Partials\Sections;

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use NckRtl\FilamentResourceTemplates\TemplateSection;

class TextSectionData extends TemplateSection
{
    const SECTION_KEY = 'text';

    public ?string $text = '';

    public static function form()
    {
        return Section::make('Content')->schema(
            [
                RichEditor::make(static::key('text'))
            ]);
    }
}

use NckRtl\FilamentResourceTemplates\TemplateResource;

class PageResource extends TemplateResource
...

public static function getTemplateClasses(): Collection
{
    return collect([
        DefaultTemplate::class,
        ...
    ]);
}