tomatophp/filament-withdrawals
Filament plugin to manage withdrawals in your admin panel. Create withdrawal methods, define custom request fields with a form builder, and review, view, and edit withdrawal requests. Includes installer command and easy plugin registration in AdminPanelProvider.
composer require tomatophp/filament-withdrawals
php artisan filament-withdrawals:install
app/Providers/Filament/AdminPanelProvider.php:
->plugin(\TomatoPHP\FilamentWithdrawals\FilamentWithdrawalsPlugin::make())
php artisan vendor:publish --tag="filament-withdrawals-lang"
php artisan vendor:publish --tag="filament-withdrawals-migrations"
Create a withdrawal method and process a request:
// Define a withdrawal method (e.g., bank transfer)
FilamentWithdrawalFormBuilder::make(1)->build();
// Submit a withdrawal request
FilamentWithdrawalFormBuilder::make(1)->send([
'amount' => 100.50,
'account' => '123456789',
'currency' => 'USD',
]);
Withdrawal Method Management
FilamentWithdrawalFormFields::register().Request Processing
$withdrawal = FilamentWithdrawalFormBuilder::make($methodId)->send($data);
Form Field Extensions
CodeEditor for verification codes):
FilamentWithdrawalFormFields::register([
WithdrawalFormFieldType::make('verification_code')
->className(TextInput::class)
->label('Verification Code')
->rules('required|digits:6'),
]);
Event-Driven Logic
WithdrawalRequested) to trigger actions like:
WithdrawalRequest::dispatch($data)->onQueue('withdrawals');
Route::post('/withdraw', [WithdrawalController::class, 'store']);
Floating-Point Precision
bcmath or round() for currency amounts to avoid precision errors:
$amount = bcdiv($request->amount, 1, 2); // Ensures 2 decimal places
Migration Conflicts
wallet was changed from integer to float in v1.0.2).Form Field Registration
WithdrawalFormFieldType contract. Missing methods will throw errors.Plugin Registration Order
PluginNotFoundException.event(new WithdrawalRequested($data));
FilamentWithdrawalFormBuilder::make(1)->setRules([
'amount' => 'required|numeric|min:0.01',
]);
Custom Withdrawal Logic Override the default processing in a service provider:
$this->app->bind(\TomatoPHP\FilamentWithdrawals\Services\Contracts\WithdrawalProcessor::class,
\App\Services\CustomWithdrawalProcessor::class);
Localization Publish and extend language files:
php artisan vendor:publish --tag="filament-withdrawals-lang"
Then add translations to resources/lang/{locale}/filament-withdrawals.php.
Testing Use the package’s test utilities to mock withdrawals:
$this->actingAs($user)
->post('/withdraw', ['method_id' => 1, 'amount' => 100.00]);
$this->assertDatabaseHas('withdrawal_requests', ['amount' => 100.00]);
How can I help you explore Laravel packages today?