@zidance A user is a user. There’s no need to create separate tables for the same information. Just use a role to designate what type of user each one is, and then authorization to determine what a user can and cannot do based on their role(s).
If a user can connect social accounts to their profile, then store these connections in their own table. Authenticating with a third-party site is usually done via OAuth. Sites like Facebook and Twitter will give you an ID for that user on that site, so you can let a user connect say, a Twitter account in their account settings on your site. You can save the Twitter ID and your user ID so that the next time the user uses Twitter to log in, you can look up the corresponding account on your site and authenticate them:
class TwitterController extends Controller
{
public function handleProviderCallback()
{
$twitterUser = Socialite::driver('twitter')->user();
// Find user associated with this Twitter account
$accessToken = AccessToken::where(function ($query) use ($twitterUser) {
$query->where('provider_type', '=', 'twitter');
$query->where('provider_id', '=', $twitterUser->getId());
})->first();
if ($accessToken) {
// Update row with fresh token and secret, and authenticate user
$accessToken->update([
'access_token' => $twitterUser->token,
'access_token_secret' => $twitterUser->token_secret,
]);
Auth::loginUsingId($accessToken->user_id);
return redirect()->intended('/');
}
// This Twitter account does not belong to any user
// Show error message instead
return redirect()
->to('/login')
->with('error', 'This Twitter account does not belong to a user account');
}
}