How can I get first name and last name from Facebook using Laravel Socialite? - laravel-socialite

How can I get first name and last name from Facebook using Laravel Socialite? By default I'm getting full name in a single field.

Socialite::driver('facebook')->fields(['first_name', 'last_name'])->user();

You can get field from provider like this.
//get the driver and set desired fields
$driver = Socialite::driver('facebook')
->fields(['name', 'first_name', 'last_name', 'email', 'gender', 'verified']);
// retrieve the user
$user = $driver->user();
follow this link for more details
Laravel Socialite first and last name

Related

NetSuite SuiteScript 2.0 get Company Name

Is there any way to get the current company name when on a transaction entry page? Either some session object, global object, or some sort. Kind of like how you can get the user name from the runtime module? I see country name, but cannot seem to get the company name. Using a client script for this.
How I get the user name:
runtime.getCurrentUser().name
thank you
Here is the working code now, but trying to figure a way to get this on a client script. Possible to pass this value?
var companyInfo = config.load({
type: config.Type.COMPANY_INFORMATION
});
var compname = companyInfo.getValue({
fieldId: 'companyname'
});
log.debug(compname);
scriptContext.form.addButton({
id: "custpage_mybutton",
label: "View Documents",
functionName: "onButtonClick"
});
scriptContext.form.clientScriptModulePath = "SuiteScripts/dl_cs_vendorbill.js";
In server side scripts you can do this:
require(['N/config'], config=>{
const info = config.load({type:config.Type.COMPANY_INFORMATION});
log.debug({title:'Current company Info', details:info.getValue({fieldId:'companyname'}));
});
For a client script you could use that code in a paired user event script.
In the before phase of the UE you'd do the lookup and then add a hidden field to the form with the company name as a value. Your client script can then look that up like any normal getValue

Firebase/nodeJS : Add new elements without disturbing the records

In this code :
firebase.database().ref('users/' + userId).set({
username: name,
email: email,
profile_picture : imageUrl
},
The existing elements of userID is deleted when executed. How to dd new elements without disturbing the existing array?
If we refer to the documentation, the set method is used to "Write or replace data to a defined path". To add new elements without replacing, you can use the "update" or "push" method. Please refer the documentation. I've added the link below.
Saving Data | Firebase Realtime Database

Custom User Registration: How to write gender to customer record

My user registration form has a custom field for Gender. How can I make SCA write the customer's gender to the NS database?
Should I use Commerce API or SuiteScript API?
I guess I should edit the model Account/SuiteScript/Account.Model.js but should I use the Commerce API (Customer object or the Profile/User object) or directly write to the database using record.setFieldValue()?
In Account/SuiteScript/Account.Model::register() function:
//#method register
//#param {UserData} user_data
//#param {Account.Model.Attributes} user_data
register: function (user_data)
{
var customer = session.getCustomer();
....default user registration code
var user = Profile.get();
// Should I do it like this?
customer.updateProfile({
"customfields": {
"custentity_dev_gender": user_data.gender
}
})
// Should I edit the user object??
// Should I interact directly with the customer record. Does Commerce API allow this??
var record = nlapiLoadRecord('customer', user.id);
record.setFieldValue('custentity_dev_gender', user_data.gender);
var internalId = nlapiSubmitRecord(record);
return {
touchpoints: session.getSiteSettings(['touchpoints']).touchpoints
, user: user
, cart: LiveOrder.get()
, address: Address.list()
, creditcard: CreditCard.list()
};
}
Its Very Simple actually no need to write record.setFieldValue()
Very first step is to create custom entity field from Customization--> Entity Field-->New
Apply the entity field to customer give edit access to field and Save.
Copy the entity id from there, in this case say 'custentity_gender_field'
The you need to override below two files, if you don't know ask separate question I'll reply there.
i.Modules/suitecommerce/LoginRegister#2.2.0/Templates/login_register_register.tpl
ii.Modules/suitecommerce/Profile#2.3.0/SuiteScript/Profile.Model.js
Go to first file write below code somewhere where you need to put gender
<div class="login-register-register-form-controls-group" data validation="control-group">
<label class="login-register-register-form-label for="custentity_gender_field">{{translate 'Gender: '}}
<small class="login-register-register-form-optional">{{translate '(optional)'}}</small>
</label>
<div class="login-register-register-form-controls" data-validation="control">
<input type="text" name="custentity_gender_field" id="custentity_gender_field" class="login-register-register-form-input">
</div>
</div>
Then Go to Second File i.e. Profile.Model.js
You can see in get function various filed values, put your custom field value there
this.fields = this.fields || ['isperson', 'email', 'internalid', 'name', 'overduebalance', 'phoneinfo', 'companyname', 'firstname', 'lastname', 'middlename', 'custentity_gender_field', 'emailsubscribe', 'campaignsubscriptions', 'paymentterms', 'creditlimit', 'balance', 'creditholdoverride'];
Deploy your code and test under user roles--> Manage User
I missed one more thing here, you need to make changes in
Account#2.2.0/SuiteScript/Account.Model.js as well in this model find
register: function (user_data)
{
}
and your custom field in
ModelsInit.session.registerCustomer(
{
custentity_gender_field:user_data.custentity_gender_field
});
That's it...

What is the 'Primary Information' field group id in NetSuite?

In my User Event script I am adding a field to the form and I would like to add it to the Primary Information field group. What is the internal id of the group? I've tried primaryinformation but that's not correct. I can't see a method of iterating field groups and fields in the API to figure it out.
Does anyone know?
I am using SS2.
var field = scriptContext.form.addField({
id: 'textfield',
type: serverWidget.FieldType.TEXT,
label: 'Text',
container: '**primaryinformation**' <--
});
From inspecting the DOM of the form, it looks like they are randomly generated identifiers in the form fieldGroupXX.
As an alternative, you could try using form.insertField(options) to place your field in the desired Field Group.

Stripe: Show Customer Name on place of Email

Stripe captures Email and Name both in StripeCustomerService(), that is when creating the customer using Stripe.dll...
But in Admin login, it shows Customer Email in heading, as shown below.
Is there any way to change it to Name of a customer?
But if I pass name in Email parameter, it may affect sending a notification email to the customer.
So, is it possible to do so?
Note: I have passed both in parameters list;
var mycust = new StripeCustomerCreateOptions();
//Save Card Details
mycust.CardNumber = txtCard.Text;
mycust.CardExpirationMonth = ddlMonth.SelectedValue;
mycust.CardExpirationYear = ddlYear.SelectedValue;
mycust.CardCvc = txtCSV.Text;
//Save Customer Details
mycust.Email = email;
mycust.CardName = fullName;
Short Answer: No, it is not possible.
There may be any number of customer's by the name of John Doe but each would have a different email such as:
JDoe#email.com, JDoe2#email.com, etc.
Email is a unique identifier while name is not.

Resources