full accounts manager with API/Notifications/Contacts to manage your contacts and accounts
- Accounts Manager
- Cached Meta
- Account Locations
- Account Teams
- Account Types
- Account Requests
- Account SaaS Panel With Edit Profile [Jetstream]
- Account Login By
- Account Active/Block
- Account Avatar
- Account OTP Activation
- Account Filament Alerts Integration
- Account Impersonate Integration
- Account APIs
- Auth Builder Service
- Support Multi Tenants
- Account Table Column
- Account Panel Events
- Attach New Field To Accounts
- Export
- Import
- Google Contacts Integrations
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())
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
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"
now you need to migrate your database
php artisan migrate
now add this method to your plugin in AdminPanelProvider.php
->plugin(
\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
->useAvatar()
)
you can use the types to manage your accounts types by install Filament Types
composer require tomatophp/filament-types
after that install types
php artisan filament-types:install
and allow ->useTypes()
on the plugin
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
->useTypes()
)
you need to install Filament Alets
composer require tomatophp/filament-alerts
after that install alerts
php artisan filament-alerts:install
and allow ->useNotifications()
on the plugin
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
->useNotifications()
)
you can use account locations by install Filament Locations
composer require tomatophp/filament-locations
after that install locations
php artisan filament-locations:install
and allow ->useLocations()
on the plugin
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
->useLocations()
)
you can show or hide addresss field on the create or edit form by using this code
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
->showAddressField()
)
you can show or hide type field on the create or edit form by using this code
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
->showTypeField()
)
you can allow Other Feature and pages like this
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
->useAccountMeta()
)
on your .env
add this
CACHE_STORE=array
MODEL_CACHE_STORE=array
supported cache stores are
+ Redis
+ MemCached
+ APC
+ Array
you can allow the requests manager by using this code
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
->useRequests()
)
you can allow the contact us manager by using this code
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
->useContactUs()
)
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')
]);
}
before use Export & Import actions you need to install laravel excel package
composer require maatwebsite/excel
now on your main panel provider add ->useExport()
, ->useImport()
to the plugin
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
...
->useExport()
->useImport()
)
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
just install the package and you will get everything working, it supports some features ready to use:
- Accounts
- Locations
- Contact Us
- Send Notifications
- Auth APIs
- Send OTP Events
you can activate or deactivate any feature you want from the package config file.
now publish your Accounts model
php artisan vendor:publish --tag="filament-accounts-model"
on your main panel you must use login functions
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsPlugin::make()
...
->canLogin()
->canBlocked()
)
now on your new panel just use this plugin
->plugin(
FilamentAccountsSaaSPlugin::make()
->databaseNotifications()
->checkAccountStatusInLogin()
->APITokenManager()
->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
install jetstream without run install command.
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()
->useTeams()
)
and on your app panel you must use this plugin
->plugin(\TomatoPHP\FilamentAccounts\FilamentAccountsSaaSPlugin::make()
->editTeam()
->deleteTeam()
->teamInvitation()
->showTeamMembers()
->allowTenants()
)
you can make your account manage the locations by using this code
->plugin(
FilamentAccountsSaaSPlugin::make()
->canManageAddress()
)
it will add Edit Locations menu to the tenant menu and the accounts can manage there locations
you can manage account requests by using this code
use TomatoPHP\FilamentAccounts\Services\Contracts\AccountRequestForm;
->plugin(
FilamentAccountsSaaSPlugin::make()
->canManageRequests(form: [
AccountRequestForm::make('account_approve')
->schema([
TextInput::make('name')
->label('Name')
->required(),
]),
AccountRequestForm::make('account_verify')
->schema([
TextInput::make('id')
->label('ID')
->numeric()
->minLength(14)
->maxLength(14)
->required(),
])
])
->useTypes()
)
as you see you can select a form the every request type.
you can manage account contact us by using this code
->plugin(
FilamentAccountsSaaSPlugin::make()
->showContactUsButton()
)
or you can use it anywhere on your app by using the livewire component
@livewire('tomato-contact-us-form')
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
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 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
Checkout our Awesome TomatoPHP