PHP code example of tomatophp / filament-types

1. Go to this page and download the library: Download tomatophp/filament-types 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/ */

    

tomatophp / filament-types example snippets


use TomatoPHP\FilamentTypes\Services\Contracts\Type;
use TomatoPHP\FilamentTypes\Services\Contracts\TypeFor;
use TomatoPHP\FilamentTypes\Services\Contracts\TypeOf;

->plugin(\TomatoPHP\FilamentTypes\FilamentTypesPlugin::make())
    ->types([
        TypeFor::make('posts')
            ->label('Posts')
            ->types([
                TypeOf::make('categories')
                    ->label('Categories')
                    ->register([
                        Type::make('news')
                            ->name('News')
                            ->icon('heroicon-o-newspaper')
                            ->color('#fefefe')
                    ])
            ])
    ])

use TomatoPHP\FilamentTypes\Facades\FilamentTypes;
use TomatoPHP\FilamentTypes\Services\Contracts\Type;
use TomatoPHP\FilamentTypes\Services\Contracts\TypeFor;
use TomatoPHP\FilamentTypes\Services\Contracts\TypeOf;

FilamentTypes::register([
    TypeFor::make('products')
        ->label('Product')
        ->types([
            TypeOf::make('sizes')
                ->label('Sizes')
                ->register([
                    Type::make('xl')
                        ->name('XL')
                        ->icon('heroicon-o-adjustments-horizontal')
                        ->color('warning'),
                    Type::make('sm')
                        ->name('SM')
                        ->icon('heroicon-o-adjustments-horizontal')
                        ->color('warning')
                ])
        ]),
]);

type_of(
    key: 'pending',
    for: 'notes',
    type: 'groups'
);

use TomatoPHP\FilamentTypes\Components\TypeColumn;

TypeColumn::make('type')
    ->for('users')
    ->type('status')
    ->allowDescription()
    ->searchable(),

+ Redis
+ MemCached
+ APC
+ Array

use TomatoPHP\FilamentTypes\Pages\BaseTypePage;

use TomatoPHP\FilamentTypes\Services\Contracts\Type;

class NotesGroups extends BaseTypePage
{
     public function getTitle(): string
    {
        return "Notes Groups";
    }

    public function getType(): string
    {
        return "groups";
    }

    public function getFor(): string
    {
        return "notes";
    }

    public function getBackUrl()
    {
        return ManageNotes::getUrl(); // TODO: Change the autogenerated stub
    }

    public function getTypes(): array
    {
        return [
            Type::make('todo')
                ->name("TODO")
                ->color('#1461e3')
                ->icon('heroicon-o-list-bullet'),
            Type::make('ideas')
                ->name("Ideas")
                ->color('#13e0da')
                ->icon('heroicon-o-sparkles'),
            Type::make('saved')
                ->name("Saved")
                ->color('#29a82e')
                ->icon('heroicon-o-arrow-down-on-square'),
        ];
    }
}

public static function shouldRegisterNavigation(): bool
{
    return true;
}

use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Table\TypeTable;

public function boot()
{
    TypeTable::register([
        \Filament\Tables\Columns\TextColumn::make('something')
    ]);
}

use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Table\TypeActions;

public function boot()
{
    TypeActions::register([
        \Filament\Tables\Actions\ReplicateAction::make()
    ]);
}

use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Table\TypeFilters;

public function boot()
{
    TypeFilters::register([
        \Filament\Tables\Filters\SelectFilter::make('something')
    ]);
}

use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Table\TypeBulkActions;

public function boot()
{
    TypeBulkActions::register([
        \Filament\Tables\BulkActions\DeleteAction::make()
    ]);
}

use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Form\TypeForm;

public function boot()
{
    TypeForm::register([
        \Filament\Forms\Components\TextInput::make('something')
    ]);
}

use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Actions\ManagePageActions;

public function boot()
{
    ManagePageActions::register([
        Filament\Actions\Action::make('action')
    ]);

}
bash
php artisan filament-types:install
bash
php artisan vendor:publish --tag="filament-types-config"
bash
php artisan vendor:publish --tag="filament-types-views"
bash
php artisan vendor:publish --tag="filament-types-lang"
bash
php artisan vendor:publish --tag="filament-types-migrations"
bash
composer analyse