Login page parameters
Hello everyone!
I've been struggling with something i'm trying to achieve and would like to ask someone to read my case and give me some advise.
Case
1. I have created my own 'Team' system and i'm working on team invitations.
2. Currently, users can receive emails in their inbox with a link to
https://xxxx.com/user/login?invitation=xxxxxxxxxxx
3. The login url/route leads to an extended class of Filament\Pages\Auth\Login
which i assigned in the UserPanelProvider in $panel->login(UserLogi::class)
4. I'm stuck at handling the extra 'invitation' parameter.
5. I may add/handle more parameters in the future for handling different kind of actions/requests.
My questions
1. How can access the 'invitation' and possibly other parameters in my UserLogin class?
2. Since i can't find any other similiar cases. Am i doing this all wrong?
What i tried
In order to understand what i tried, you might wanna check out my code below first.
1. In my public function form(Form $form)
or public function __construct()
when i do dd(request('invite')
i can see the value of the parameter.
2. But in my public function beforeAuthenticate()
it returns null
3. I've tried to set a parameter in my constructor but it gets set back to null when i'm in my public function authenticate()
My code
2 Replies
How can access the 'invitation' and possibly other parameters in my UserLogin class?You can use
mount()
and get request('invite')
and assign it to variable. Ref: https://livewire.laravel.com/docs/lifecycle-hooks#mountProblem solved, thank you!
Livewire doc:
Mount
In a standard PHP class, a constructor (construct()) takes in outside parameters and initializes the object's state. However, in Livewire, you use the mount() method for accepting parameters and initializing the state of your component.
Livewire components don't use construct() because Livewire components are re-constructed on subsequent network requests, and we only want to initialize the component once when it is first created.