Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,23 @@ public static function table(Table $table): Table
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\Action::make('view_on_stripe')
->label('View on Stripe')
->color('gray')
->icon('heroicon-o-arrow-top-right-on-square')
->url(fn (User $record) => 'https://dashboard.stripe.com/customers/'.$record->stripe_id)
->openUrlInNewTab()
->visible(fn (User $record) => filled($record->stripe_id)),
Tables\Actions\Action::make('view_on_anystack')
->label('View on Anystack')
->color('gray')
->icon('heroicon-o-arrow-top-right-on-square')
->url(fn (User $record) => 'https://app.anystack.sh/contacts/'.$record->anystack_contact_id)
->openUrlInNewTab()
->visible(fn (User $record) => filled($record->anystack_contact_id)),
Tables\Actions\ActionGroup::make([
Tables\Actions\EditAction::make(),
Tables\Actions\Action::make('view_on_stripe')
->label('View on Stripe')
->color('gray')
->icon('heroicon-o-arrow-top-right-on-square')
->url(fn (User $record) => 'https://dashboard.stripe.com/customers/'.$record->stripe_id)
->openUrlInNewTab()
->visible(fn (User $record) => filled($record->stripe_id)),
Tables\Actions\Action::make('view_on_anystack')
->label('View on Anystack')
->color('gray')
->icon('heroicon-o-arrow-top-right-on-square')
->url(fn (User $record) => 'https://app.anystack.sh/contacts/'.$record->anystack_contact_id)
->openUrlInNewTab()
->visible(fn (User $record) => filled($record->anystack_contact_id)),
])->label('Actions')->icon('heroicon-m-ellipsis-vertical'),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Expand Down
117 changes: 69 additions & 48 deletions app/Filament/Resources/UserResource/Pages/EditUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,81 @@ class EditUser extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\Action::make('createStripeCustomer')
->label('Create Stripe Customer')
->color('gray')
->icon('heroicon-o-credit-card')
->action(function (User $record) {
if ($record->hasStripeId()) {
Notification::make()
->danger()
->title('User is already a Stripe customer.')
->send();
Actions\ActionGroup::make([
Actions\Action::make('createStripeCustomer')
->label('Create Stripe Customer')
->color('gray')
->icon('heroicon-o-credit-card')
->action(function (User $record) {
if ($record->hasStripeId()) {
Notification::make()
->danger()
->title('User is already a Stripe customer.')
->send();

return;
}
return;
}

$record->createOrGetStripeCustomer();
})
->visible(fn (User $record) => empty($record->stripe_id)),
$record->createOrGetStripeCustomer();
})
->visible(fn (User $record) => empty($record->stripe_id)),

Actions\Action::make('createAnystackLicense')
->label('Create Anystack License')
->color('gray')
->icon('heroicon-o-key')
->form([
\Filament\Forms\Components\Select::make('subscription')
->label('Subscription Plan')
->options(collect(\App\Enums\Subscription::cases())->mapWithKeys(function ($case) {
return [$case->value => $case->name()];
}))
->required(),
])
->action(function (array $data, User $record) {
$subscription = \App\Enums\Subscription::from($data['subscription']);
Actions\Action::make('createAnystackLicense')
->label('Create Anystack License')
->color('gray')
->icon('heroicon-o-key')
->form([
\Filament\Forms\Components\Select::make('subscription')
->label('Subscription Plan')
->options(collect(\App\Enums\Subscription::cases())->mapWithKeys(function ($case) {
return [$case->value => $case->name()];
}))
->required(),
])
->action(function (array $data, User $record) {
$subscription = \App\Enums\Subscription::from($data['subscription']);

\App\Jobs\CreateAnystackLicenseJob::dispatch(
$record,
$subscription,
null,
$record->first_name,
$record->last_name,
);
}),
\App\Jobs\CreateAnystackLicenseJob::dispatch(
$record,
$subscription,
null,
$record->first_name,
$record->last_name,
);
}),

Actions\Action::make('sendPasswordReset')
->label('Send Password Reset')
->color('gray')
->icon('heroicon-o-envelope')
->requiresConfirmation()
->action(function (User $record) {
\Illuminate\Support\Facades\Password::sendResetLink(
['email' => $record->email]
);
}),
Actions\Action::make('sendPasswordReset')
->label('Send Password Reset')
->color('gray')
->icon('heroicon-o-envelope')
->requiresConfirmation()
->action(function (User $record) {
\Illuminate\Support\Facades\Password::sendResetLink(
['email' => $record->email]
);
}),

Actions\DeleteAction::make(),
Actions\Action::make('view_on_stripe')
->label('View on Stripe')
->color('gray')
->icon('heroicon-o-arrow-top-right-on-square')
->url(fn (User $record) => 'https://dashboard.stripe.com/customers/'.$record->stripe_id)
->openUrlInNewTab()
->visible(fn (User $record) => filled($record->stripe_id)),

Actions\Action::make('view_on_anystack')
->label('View on Anystack')
->color('gray')
->icon('heroicon-o-arrow-top-right-on-square')
->url(fn (User $record) => 'https://app.anystack.sh/contacts/'.$record->anystack_contact_id)
->openUrlInNewTab()
->visible(fn (User $record) => filled($record->anystack_contact_id)),

Actions\DeleteAction::make(),

])
->label('Actions')
->icon('heroicon-m-ellipsis-vertical'),
];
}
}