I am working on Symfony 4.2, I fetched the session in my controller like:
$data = $this->get('security.token_storage')->getToken()->getUser();
when I
dump($data);
gives me,
DashboardController.php on line 17:
User {#504 ▼
-id: 1
-f_name: "Kumar"
-l_name: "Saurabh"
-username: "supa-admin"
-password: "$2y$12$qerXOggk6RdKjoE1J4R5I.OzvSYuGdq6E.m1bZp.cPMxolCd/F1xm"
-email: "some_email@gmail.com"
-address: Address {#525 ▶}
-contact: 78954
-gender: "male"
-age: 26
}
Here, How can I get 'f_name' from this object?
looks like you need to create setters and getters within your User model/entity. Or you could create a __get() / __set() function within the same model / entity to get this information.