Pass the value of navigationLabel to create page
So, I have a Students table and it has a field called gametype, which is basically hidden from the user, its in my SQL Table only.
What I have is that multiple types of sports and I am saving their data in the same sql table, so whenever I want to show players in Badminton, I just run a condition and show student with gametype Badminton, so what I want to do is that when I create a record from Badminton resource, I want the create page to know that I am coming from the Badminton page so the value of gametype should be Badminton etc
Even better if I can keep that hidden but if I need to put that value in the form builder to have it save in the database, I will just use a disabled input field for it
20 Replies
Also is there a way I can pass the name of the logged in user as brandname in admin panel provider?
we dont know your code mate, show it.. it tells us more than this whole paragraph xd
code please
Sorry I'm kind of new to Laravel
not an entire duuuump xD.. pinpoint what you want and what you tried.. read the #β
βrules .. help us help you and what not
Let me edit this xD
Basically the $id needs to have the name of the current logged in user and I want to just dynamically change the name of the dashboard
I tried using this too hoping it may just give the ID even but atleast this code doesnt give me an error
$id = Auth::id();
Otherwise it prob throws user is null on the login screen?
for some reason the name property doesnt exist, is there a way I can console the auth()->user() to see if it returns anything?
ps.. dont use variable when you are just using them directly and dont need them for anything else.. bad practice.. no need for $id or $name ^^
are you logged in?
if you are not.. there is no name as there is no user
what do you actually want the brandname to be? it beeing different for every user seems odd to me tbh haha
I am logged in, is it possible its happening because I did the remember me?
I can see my dashboard and everything and I see the 'default name' now
nah, doesnt change anything about the authenticated user
just sets the remember token
I have a column in my table that has value of their sports club so I want to later on set it as that but keeping it simple to name for now
Is it possible that AdminPanelProvider does the authentication later?
Solution
as a closure?
works for me
let me check by writing exactly this
Oh this worked! I guess I needed the fn call, THANK YOU SO MUCH!!!!
the same can be done for the clubname column?
->brandName(fn () => auth()->user()->clubname);
as long it is set, yeah.. just watch out for the login page..
it will throw attempt to read x on null
cus there is no auth user on the login page
so you would need
so its nullsafe
Okay, I will do that, thanks alot, sorry for the trouble!
Really appreciate it !
all good
Adding this here as it's somewhat related: https://filamentphp.com/docs/3.x/panels/users#configuring-the-users-name-attribute
Thank you