ryangjchandler/filament-user-resource

A simple resource for managing users in Filament.

v0.3.0 2023-04-17 16:28 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a UserResource class that lets you create and update User models from Filament. This is designed to work with Laravel's default User model.

Installation

You can install the package via Composer:

composer require ryangjchandler/filament-user-resource

You can publish the config file with:

php artisan vendor:publish --tag="filament-user-resource-config"

Usage

The UserResource class is automatically registered with Filament so there's very little setup.

Enabling password changes

By default, the password for a User can't be updated from Filament. This is a personal preference, but can be enabled by calling UserResource::enablePasswordUpdates() inside of a service provider.

use RyanChandler\FilamentUserResources\Resources\UserResource;

public function boot()
{
    UserResource::enablePasswordUpdates();
}

You can also provide a callback function to this method to conditionally enable password updates, e.g. allowing administrators to update passwords but not other users.

use RyanChandler\FilamentUserResources\Resources\UserResource;

public function boot()
{
    UserResource::enablePasswordUpdates(function (): bool {
        return auth()->user()->role === Role::Admin;
    });
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.