Accessing Shield User entity properties |
When I use the helper and reference
PHP Code: auth()->user()->attributes it's always NULL. If I dd() or var_dump() auth()->user() though, it shows $attributes is an array with juicy values like 'username'. How do I get that juice? Also, where did the forum search go? (09-01-2024, 10:23 PM)evansharp Wrote: When I use the helper and referenceIt's on the very top of the forums in the ToolBar. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
You need to make sure they are logged in first. If a user is not logged in, `auth()->user()` will return `null`, and you won't be able to retrieve their details.
(09-02-2024, 05:23 PM)datamweb Wrote: You need to make sure they are logged in first. If a user is not logged in, `auth()->user()` will return `null`, and you won't be able to retrieve their details. `auth()->user()` does not return null though. If I `dd()` the object returned, I can see all the properties and methods. I get null when I try to access those properties though with `auth()->user()->attributes`. (09-01-2024, 10:41 PM)InsiteFX Wrote:ToolBar wasn't displaying. It is now though.(09-01-2024, 10:23 PM)evansharp Wrote: When I use the helper and referenceIt's on the very top of the forums in the ToolBar. Code: ¯\_(ツ)_/¯
User extend Entity?
$atteibutes this is a protected property, it cannot be read outside the class. Try toArray() https://codeigniter4.github.io/userguide...properties (09-02-2024, 08:45 PM)ozornick Wrote: User extend Entity? Excellent, thanks! |
Welcome Guest, Not a member yet? Register Sign In |