How on filamentphp site with custom register to move to profile page ?
On laravel 10 / filamentphp 3 site with multi tenancy I made custom register page with additive columns and code in app/Providers/Filament/AppPanelProvider.php :
<?php
namespace App\Providers\Filament;
use App\Filament\App\Pages\Auth\Register; // I define custom Register page
use App\Filament\App\Pages\Tenancy\RegisterBranch;
use App\Models\Branch;
use Filament\PanelProvider;
...
class AppPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->plugins([ ])
->id('app')
->path('app')
->login()
->profile()
->registration(Register::class)
I define custom Register page as I need with creating User model to add 2 additive models and in app/Filament/Pages/Auth/MyCustomRegister.php I call aditive event :
<?php
namespace App\Filament\Pages\Auth;
use App\Events\UserRegisteredEvent;
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
use Filament\Facades\Filament;
use Filament\Forms\Form;
use Filament\Http\Responses\Auth\Contracts\RegistrationResponse;
use Filament\Notifications\Notification;
use Filament\Pages\Auth\Register;
/**
* @property Form $form
*/
class MyCustomRegister extends Register // SimplePage
{
public function register(): ?RegistrationResponse
{
try {
$this->rateLimit(2);
} catch (TooManyRequestsException $exception) {
Notification::make()
->title(__('filament-panels::pages/auth/register.notifications.throttled.title', [
'seconds' => $exception->secondsUntilAvailable,
'minutes' => ceil($exception->secondsUntilAvailable / 60),
]))
->body(array_key_exists('body', __('filament-panels::pages/auth/register.notifications.throttled') ?: []) ? __('filament-panels::pages/auth/register.notifications.throttled.body', [
'seconds' => $exception->secondsUntilAvailable,
'minutes' => ceil($exception->secondsUntilAvailable / 60),
]) : null)
->danger()
->send();
return null;
}
$data = $this->form->getState();
$user = $this->getUserModel()::create($data);
$this->sendEmailVerificationNotification($user);
Filament::auth()->login($user);
session()->regenerate();
$request= request();
UserRegisteredEvent::dispatch($user, $this->data); // I call event to add more models
// if to uncomment line below I got error that RegistrationResponse must be returned
// return redirect()->route('filament.app.auth.profile')->with('message', $user->name . ' was registered !');
return app(RegistrationResponse::class);
}
}
But page for entering of new tenant "app/new" is opened. I routes I found lines:
GET|HEAD app/new ........................................................................................................... filament.app.tenant.registration › App\Filament\App\Pages\Tenancy\RegisterBranch
GET|HEAD app/profile ............................................................................................................................... filament.app.auth.profile › Filament\Pages › EditProfile
to move to profile page
In filamentphp docs I did not find any RegistrationResponse reference, which is in vendor/filament/filament/src/Http/Responses/Auth/Contracts/RegistrationResponse.php file :
namespace Filament\Http\Responses\Auth\Contracts;
use Illuminate\Contracts\Support\Responsable;
interface RegistrationResponse extends Responsable
{
}
Have I declare RegistrationResponse with redirect to 'filament.app.auth.profile' ? How ? Or in some other way ?
"laravel/framework": "^10.28.0",
"filament/filament": "^3.0-stable",
Thanks in advance !
Please or to participate in this conversation.