I am trying to implement Gmail API for CRM based on laravel, where users can store multiple Google credentials, and using those credentials users can log in with their Google account.
I used dacastro4 laravel-gmail package, but for dacastro4/laravel-gmail
package by default design, those Google credentials are stored in .env file of the laravel project.
.env
GOOGLE_PROJECT_ID=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=
`
I tried setting the .env variable in the controller constructor function, but not working. for example,
env('GOOGLE_PROJECT_ID',$project_id);
//OR
putenv("GOOGLE_PROJECT_ID=".$project_id);
//OR
config(['GOOGLE_PROJECT_ID' => $project_id])
Also tried setting in the vendor dacastro4 laravel-gmail package, but the database model is not accessible.
How can I set multiple Google credentials from the controller?
Thank You.
You can set this data using the
config()
method, seeing as that's how Laravel accesses.env
variables.Create a config file for your variables:
config/gmail.php
Then set values in your controller on the go using:
and retrieve the values using: