PHP code example of tomatophp / filament-users

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


->plugin(\TomatoPHP\FilamentUsers\FilamentUsersPlugin::make())

use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;

    // ...
}

->plugin(\BezhanSalleh\FilamentShield\FilamentShieldPlugin::make())

/*
 * User Filament Shield
 */
"shield" => true,

/*
 * User Filament Impersonate
 */
"impersonate" => true,

'features' => [
//     Features::termsAndPrivacyPolicy(),
//     Features::profilePhotos(),
//     Features::api(),
     Features::teams(['invitations' => true]),
//     Features::accountDeletion(),
],

/*
 * User Filament Teams
 */
"teams" => true,

use TomatoPHP\FilamentUsers\Facades\FilamentUser;

public function boot()
{
    FilamentUser::register([
        \Filament\Resources\RelationManagers\RelationManager::make() // Replace with your custom relation manager
    ]);
}

use TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserTable;

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

use TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserActions;

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

use TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserFilters;

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

use TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserBulkActions;

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

use TomatoPHP\FilamentUsers\Resources\UserResource\Form\UserForm;

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

use TomatoPHP\FilamentUsers\Resources\UserResource\Actions\ManageUserActions;
use TomatoPHP\FilamentUsers\Resources\UserResource\Actions\EditPageActions;
use TomatoPHP\FilamentUsers\Resources\UserResource\Actions\ViewPageActions;
use TomatoPHP\FilamentUsers\Resources\UserResource\Actions\CreatePageActions;

public function boot()
{
    ManageUserActions::register([
        Filament\Actions\Action::make('action')
    ]);
    
    EditPageActions::register([
        Filament\Actions\Action::make('action')
    ]);
    
    ViewPageActions::register([
        Filament\Actions\Action::make('action')
    ]);
    
    CreatePageActions::register([
        Filament\Actions\Action::make('action')
    ]);
}

use TomatoPHP\FilamentUsers\Resources\UserResource\Infolist\UserInfolist;

public function boot()
{
    UserInfolist::register([
       \Filament\Infolists\Components\TextEntry::make('something')
    ]);
}

/**
 * ---------------------------------------------
 * Resource Building
 * ---------------------------------------------
 * if you want to use the resource custom class
 */
'resource' => [
    'table' => [
        'class' => \TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserTable::class,
        'filters' => \TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserFilters::class,
        'actions' => \TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserActions::class,
        'bulkActions' => \TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserBulkActions::class,
    ],
    'form' => [
        'class' => \TomatoPHP\FilamentUsers\Resources\UserResource\Form\UserForm::class
    ],
    'infolist' => [
        'class' => \TomatoPHP\FilamentUsers\Resources\UserResource\InfoList\UserInfoList::class
    ],
    'pages' => [
        'list' => \TomatoPHP\FilamentUsers\Resources\UserResource\Actions\ManageUserActions::class,
        'create' => \TomatoPHP\FilamentUsers\Resources\UserResource\Actions\CreatePageActions::class,
        'edit' => \TomatoPHP\FilamentUsers\Resources\UserResource\Actions\EditPageActions::class,
        'view' => \TomatoPHP\FilamentUsers\Resources\UserResource\Actions\ViewPageActions::class
    ]
]

/**
 * ---------------------------------------------
 * Use Simple Resource
 * ---------------------------------------------
 * change the resource from pages to modals by allow simple resource.
 */
'simple' => true,
bash
php artisan shield:install
bash
php artisan vendor:publish --tag="filament-users-config"
bash
php artisan config:cache
bash
php artisan config:cache
bash
php artisan jetstream:install livewire
bash
php artisan vendor:publish --tag=jetstream-teams-migrations
bash
php artisan migrate
bash
php artisan config:cache
bash
php artisan filament-users:publish
bash
php artisan vendor:publish --tag="filament-users-config"
bash
php artisan vendor:publish --tag="filament-users-lang"
bash
composer analyse