PHP code example of jeffersongoncalves / filament-user

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

    

jeffersongoncalves / filament-user example snippets


namespace App\Models;

use JeffersonGoncalves\Filament\User\Models\User as BaseUser;

class User extends BaseUser
{
    // add traits (e.g. HasTeamsFilament), relations or overrides here
}

// config/filament-user.php
'panel_access' => [
    'denied_panels' => ['admin'],
    '

use Filament\Panel;
use JeffersonGoncalves\Filament\User\Facades\PanelAccess;

PanelAccess::using(fn (User $user, Panel $panel): bool => $user->status && $panel->getId() === 'app');

use JeffersonGoncalves\Filament\User\Pages\Auth\Login;
use JeffersonGoncalves\Filament\User\UserPlugin;

// Panel where users sign in: only active users (status = true) can log in
$panel->login(Login::class);

// Panel that manages users (usually the admin panel)
$panel->plugins([
    UserPlugin::make()
        ->impersonate(guard: 'web', redirectTo: '/app'),
]);

use Filament\Tables\Enums\RecordActionsPosition;

UserPlugin::make()
    ->withoutImpersonation()       // hide the impersonate action (table, View and Edit pages)
    ->navigationGroup('Access')    // custom navigation group; false = no group
    ->groupRecordActions()         // wrap the table's record actions in one ActionGroup dropdown
    ->recordActionsPosition(RecordActionsPosition::BeforeColumns); // null = table/global default

use JeffersonGoncalves\Filament\User\Resources\Users\Schemas\UserForm;
use JeffersonGoncalves\Filament\User\Resources\Users\UserResource;

class MyUserForm extends UserForm
{
    public static function components(): array
    {
        return [
            ...parent::components(),
            TextInput::make('phone'),
        ];
    }
}

class MyUserResource extends UserResource
{
    public static function form(Schema $schema): Schema
    {
        return MyUserForm::configure($schema);
    }
}

UserPlugin::make()->resource(MyUserResource::class);
bash
php artisan vendor:publish --tag="filament-user-config"
bash
php artisan vendor:publish --tag="filament-user-translations"