I’m a beginner with Laravel, but have been coding PHP for many years. Presently I have a project where I am using “adldap2-laravel” to connect to our Active Directory. The email address is not used for the user login, so I had to make changes per the “adldap2” instructions for using “username”. However, there are times in the app where I need to use some user information that is not part of “Auth::user()”. In this case, the user’s email address.
I need a way to access the user’s email address for use within some of my methods. Otherwise I have to build it within a method, like this. Auth::user()->email = Auth::user()->username . "@mydomain.net"; Or $ useremail = Auth::user()->username . "@mydomain.net";
This is not ideal, as it is not retained in the Auth::user() since it was created in the method.
So I could do this one of two ways. Both in which I need some guidance.
Create a new field in the users table to hold the “useremail” address, which would also be created using code to concatenate username with “@mydomain.net”.
Do the concatenation mention above in some sort of boot or login file.
Ideally, both of these would have the end result as part of the Auth::user() for ease of access any time. BTW, I am using Laravel version 5.4
Suggestions with instructions would be very much appreciated.