Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Withdrawals Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation
    composer require tomatophp/filament-withdrawals
    php artisan filament-withdrawals:install
    
  2. Register Plugin Add to app/Providers/Filament/AdminPanelProvider.php:
    ->plugin(\TomatoPHP\FilamentWithdrawals\FilamentWithdrawalsPlugin::make())
    
  3. Publish Assets (Optional)
    php artisan vendor:publish --tag="filament-withdrawals-lang"
    php artisan vendor:publish --tag="filament-withdrawals-migrations"
    

First Use Case

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',
]);

Implementation Patterns

Core Workflows

  1. Withdrawal Method Management

    • Use the built-in Filament UI to configure withdrawal methods (e.g., bank, crypto, PayPal).
    • Customize fields per method via FilamentWithdrawalFormFields::register().
  2. Request Processing

    • Frontend: Integrate a form in your app to submit withdrawal requests.
    • Backend: Validate and process via:
      $withdrawal = FilamentWithdrawalFormBuilder::make($methodId)->send($data);
      
  3. Form Field Extensions

    • Extend the form builder with custom fields (e.g., CodeEditor for verification codes):
      FilamentWithdrawalFormFields::register([
          WithdrawalFormFieldType::make('verification_code')
              ->className(TextInput::class)
              ->label('Verification Code')
              ->rules('required|digits:6'),
      ]);
      
  4. Event-Driven Logic

    • Listen to withdrawal events (e.g., WithdrawalRequested) to trigger actions like:
      • Sending notifications.
      • Updating user balances.
      • Logging transactions.

Integration Tips

  • Laravel Cashier/Stripe: Sync withdrawal methods with payment gateways.
  • Queue Jobs: Defer processing for high-volume requests:
    WithdrawalRequest::dispatch($data)->onQueue('withdrawals');
    
  • API Endpoints: Expose withdrawal methods via API:
    Route::post('/withdraw', [WithdrawalController::class, 'store']);
    

Gotchas and Tips

Pitfalls

  1. Floating-Point Precision

    • Use bcmath or round() for currency amounts to avoid precision errors:
      $amount = bcdiv($request->amount, 1, 2); // Ensures 2 decimal places
      
  2. Migration Conflicts

    • If publishing migrations, check for column conflicts (e.g., wallet was changed from integer to float in v1.0.2).
  3. Form Field Registration

    • Ensure custom fields implement WithdrawalFormFieldType contract. Missing methods will throw errors.
  4. Plugin Registration Order

    • Register the plugin after Filament’s core resources to avoid PluginNotFoundException.

Debugging

  • Log Withdrawal Events Use Laravel’s logging to trace requests:
    event(new WithdrawalRequested($data));
    
  • Validate Form Data Override the default validation rules in your provider:
    FilamentWithdrawalFormBuilder::make(1)->setRules([
        'amount' => 'required|numeric|min:0.01',
    ]);
    

Extension Points

  1. Custom Withdrawal Logic Override the default processing in a service provider:

    $this->app->bind(\TomatoPHP\FilamentWithdrawals\Services\Contracts\WithdrawalProcessor::class,
        \App\Services\CustomWithdrawalProcessor::class);
    
  2. Localization Publish and extend language files:

    php artisan vendor:publish --tag="filament-withdrawals-lang"
    

    Then add translations to resources/lang/{locale}/filament-withdrawals.php.

  3. 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]);
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky