full accounts manager with API/Notifications/Contacts to manage your contacts and accounts
composer require tomatophp/filament-accounts
after install your package please run this command
php artisan filament-accounts:install
if you are not using this package as a plugin please register the plugin on /app/Providers/Filament/AdminPanelProvider.php
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make() ->useAccountMeta() ->showAddressField() ->showTypeField() ->useRequests() ->useContactUs() ->useLoginBy() ->useAvatar() ->useAPIs())
NOTE To make ->useAvatar()
work you need the Media Library plugin to be installed and migrated you can use this command to publish the migration
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-migrations"
you can publish your account model to add other relations or implement some interfaces by using this command
php artisan vendor:publish --tag="filament-accounts-model"
now go to your filament-accounts.php
config file and change the model value to the new one.
if you don't find it you can publish it
php artisan vendor:publish --tag="filament-accounts-config"
now you need to add a new guard to your auth.php config like this
<?php return [ /* * Features of Tomato CRM * * accounts: Enable/Disable Accounts Feature */ "features" => [ "accounts" => true, "meta" => true, "locations" => true, "contacts" => true, "requests" => true, "notifications" => true, "loginBy" => true, "avatar" => true, "types" => true, "teams" => true, "apis" => true, "send_otp" => true, "impersonate" => [ 'active'=> true, 'redirect' => '/app', ], ], /* * Accounts Configurations * * resource: User Resource Class */ "resource" => null, /* * Accounts Configurations * * login_by: Login By Phone or Email */ "login_by" => "email", /* * Accounts Configurations * * required_otp: Enable/Disable OTP Verification */ "required_otp" => true, /* * Accounts Configurations * * model: User Model Class */ "model" => \TomatoPHP\FilamentAccounts\Models\Account::class, /* * Accounts Configurations * * guard: Auth Guard */ "guard" => "accounts",];
this plugin makes it easy to make a starting point for your app if this app has customers to manage
but here is the problem, every app has a different way of managing customers, so we built a Facade service to control the way you want to manage your customers
on your .env
add this
CACHE_STORE=arrayMODEL_CACHE_STORE=array
supported cache stores are
+ Redis+ MemCached+ APC+ Array
install jetstream without install it.
composer require laravel/jetstream
than publish the migrations
php artisan vendor:publish --tag=filament-accounts-teams-migrations
now you need to migrate your database
php artisan migrate
now publish your Accounts model
php artisan vendor:publish --tag="filament-accounts-model"
inside your published model use this implementation
class Account extends Authenticatable implements HasMedia, FilamentUser, HasAvatar, HasTenants, HasDefaultTenant{ ... use InteractsWithTenant;}
on your main panel you must use teams
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make() ... ->canLogin() ->canBlocked() ->useTeams())
now on your new panel just use this plugin
->plugin( FilamentAccountsSaaSPlugin::make() ->databaseNotifications() ->checkAccountStatusInLogin() ->APITokenManager() ->editTeam() ->deleteTeam() ->teamInvitation() ->showTeamMembers() ->editProfile() ->editPassword() ->browserSesstionManager() ->deleteAccount() ->editProfileMenu() ->registration() ->useOTPActivation(),)
you can change settings by remove just methods from plugin.
NOTE to use ->useOTPActivation()
you need to install Filament Alets from the next step first, and to use ->databaseNotifications()
you need to publish notification database table first
to make ->useOTPActivation()
work you need to install Filament Alets and allow ->useNotifications()
on the plugin
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make() ... ->useNotifications())
you can use account locations by install Filament Locations and allow ->useLocations()
on the plugin
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make() ... ->useLocations())
you can use the types to manage your accounts types by install Filament Types and allow ->useTypes()
on the plugin
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make() ... ->useTypes())
you can use the account column in any table by using this code
public static function table(Table $table): Table{ return $table ->columns([ AccountColumn::make('account.id'), ]);}
just pass the account id to the column
you can use the impersonate to impersonate the user by install it first
composer require stechstudio/filament-impersonate
now on your main panel provider add ->useImpersonate()
, ->impersonateRedirect('/app')
to the plugin
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make() ... ->useImpersonate() ->impersonateRedirect('/app'))
now clear your config
php artisan config:cache
for more information check the Filament Impersonate
just install the package and you will get everything working, it supports some features ready to use:
you can activate or deactivate any feature you want from the package config file.
you can custom the validation rules for creating / editing accounts by just passing the rules you want to the facade service method
 use TomatoPHP\FilamentAccounts\Facades\FilamentAccounts; public function boot(){ FilamentAccounts::validation( create: [ 'email' => 'unique:accounts,email', 'type_id' => 'required|integer|exists:types,id', ], edit: [ 'email' => 'sometimes|unique:accounts,email', 'type_id' => 'sometimes|integer|exists:types,id', ], api_create: [ 'email' => 'unique:accounts,email', 'type_id' => 'required|integer|exists:types,id', ], api_edit: [ 'email' => 'sometimes|unique:accounts,email', 'type_id' => 'sometimes|integer|exists:types,id', ] ); }
by using this method you can custom the validation rules for creating / editing accounts on the web and APIs
you can attach a new field to the accounts table by just passing the field name and the field type to the facade service method
 use TomatoPHP\FilamentAccounts\Facades\FilamentAccounts; public function boot(){ FilamentAccounts::attach( key: 'birthday', label: __('Birthday'), type: 'date', show_on_create: false, show_on_edit: false );}
you can attach a new relation to the accounts relations manager by just passing the relation class to the facade service method
use TomatoPHP\FilamentAccounts\Facades\FilamentAccounts;Â public function boot(){ FilamentAccounts::registerAccountRelation([ AccountOrdersRelationManager::make() ]);}
you can attach a new button to the accounts table by just passing the button class to the facade service method
use TomatoPHP\FilamentAccounts\Facades\FilamentAccounts;Â public function boot(){ FilamentAccounts::registerAccountActions([ \Filament\Tables\Actions\Action::make('orders') ]);}
we have added a lot of events to the package, so you can listen to them and do what you want.
use TomatoPHP\FilamentAccounts\Events\SendOTP;use TomatoPHP\FilamentAlerts\Services\SendNotification;Â public function register(){ Event::listen([ SendOTP::class ], function ($data) { $user = $data->model::find($data->modelId);Â SendNotification::make(['email']) ->title('OTP') ->message('Your OTP is ' . $user->otp_code) ->type('info') ->database(false) ->model(Account::class) ->id($user->id) ->privacy('private') ->icon('bx bx-user') ->url(url('/')) ->fire(); });}
When the user logs in successfully, we fire this event.
use TomatoPHP\FilamentAccounts\Events\AccountLogged;Â public function register(){ Event::listen([ AccountLogged::class ], function ($data) { $user = $data->model::find($data->modelId); if($user->meta('is_admin_approve') !== 'yes'){ return response()->json([ "status" => false, "message" => __('your Account is activated. but you cannot login till admin approve.'), ], 400)->send(); } });}
When the user registers successfully, we fire this event.
use TomatoPHP\FilamentAccounts\Events\AccountLogged;Â public function register(){ Event::listen([ AccountRegistered::class ], function ($data) { $user = $data->model::find($data->modelId); $user->last_login = Carbon::now(); $user->save(); });}
you can build multi-auth using the same accounts table in a very easy way, so we created a Facade class to help you do that.
you just need to create 2 controllers AuthController
, ProfileController
 use TomatoPHP\FilamentAccounts\Services\Traits\Auth\Login;use TomatoPHP\FilamentAccounts\Services\Traits\Auth\Register;use TomatoPHP\FilamentAccounts\Services\Traits\Auth\Otp;use TomatoPHP\FilamentAccounts\Services\Traits\Auth\ResetPassword; class AuthController extends Controller{ use Login; use Register; use Otp; use ResetPassword; public string $guard = 'web'; public bool $otp = true; public string $model = Account::class; public string $loginBy = 'email'; public string $loginType = 'email'; public ?string $resource = null; public function __construct() { $this->guard = config('filament-accounts.guard'); $this->otp = config('filament-accounts.required_otp'); $this->model = config('filament-accounts.model'); $this->loginBy = config('filament-accounts.login_by'); $this->loginType = config('filament-accounts.login_by'); $this->resource = config('filament-accounts.resource', null); }
and on your profile controller, you just need to use Profile
traits
use TomatoPHP\FilamentAccounts\Services\Traits\Auth\Profile\User;use TomatoPHP\FilamentAccounts\Services\Traits\Auth\Profile\Update;use TomatoPHP\FilamentAccounts\Services\Traits\Auth\Profile\Delete;use TomatoPHP\FilamentAccounts\Services\Traits\Auth\Profile\Logout;Â class ProfileController extends Controller{ use User; use Update; use Delete; use Logout;Â public string $guard = 'web'; public bool $otp = true; public string $model = Account::class; public string $loginBy = 'email'; public string $loginType = 'email'; public ?string $resource = null;Â public function __construct() { $this->guard = config('filament-accounts.guard'); $this->otp = config('filament-accounts.required_otp'); $this->model = config('filament-accounts.model'); $this->loginBy = config('filament-accounts.login_by'); $this->loginType = config('filament-accounts.login_by'); $this->resource = config('filament-accounts.resource', null); }}
we have added a lot of APIs to the package, so you can use them to manage your accounts. please check this file API Collection
you can join our discord server to get support TomatoPHP
you can check docs of this package on Docs
Please see CHANGELOG for more information on what has changed recently.
Please see SECURITY for more information about security.
The MIT License (MIT). Please see License File for more information.