or
+
+
+ @foreach($this->social_providers as $provider)
+
+ @endforeach
+ {{--
+
+
+
+ --}}
+
+ @endif
+
@endvolt
diff --git a/routes/web.php b/routes/web.php
index 88bcf36..57a16bb 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,9 +1,11 @@
name('login');
@@ -16,4 +18,11 @@
Route::get('verify-email/{id}/{hash}', VerifyEmailController::class)
->middleware(['signed', 'throttle:6,1'])
->name('verification.verify');
+});
+
+
+Route::middleware(['web'])->group(function () {
+ // Add social routes
+ Route::get('auth/{driver}/redirect', [SocialController::class, 'redirect']);
+ Route::get('auth/{driver}/callback', [SocialController::class, 'callback']);
});
\ No newline at end of file
diff --git a/src/AuthServiceProvider.php b/src/AuthServiceProvider.php
index ec08dc5..79269c0 100644
--- a/src/AuthServiceProvider.php
+++ b/src/AuthServiceProvider.php
@@ -20,7 +20,7 @@ public function boot()
*/
// $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'auth');
$this->loadViewsFrom(__DIR__.'/../resources/views', 'auth');
- // $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
+ $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
$this->registerAuthFolioDirectory();
diff --git a/src/Http/Controllers/SocialController.php b/src/Http/Controllers/SocialController.php
new file mode 100644
index 0000000..3185195
--- /dev/null
+++ b/src/Http/Controllers/SocialController.php
@@ -0,0 +1,23 @@
+redirect();
+ }
+
+ public function callback(Request $request, $driver)
+ {
+ $user = Socialite::driver($driver)->user();
+ dd($user);
+ }
+}
diff --git a/src/Models/SocialProvider.php b/src/Models/SocialProvider.php
new file mode 100644
index 0000000..1ea2377
--- /dev/null
+++ b/src/Models/SocialProvider.php
@@ -0,0 +1,43 @@
+ 'array',
+ 'parameters' => 'array',
+ 'override_scopes' => 'boolean',
+ 'stateless' => 'boolean'
+ ];
+
+ // Define a relationship with the SocialProviderUser model
+ public function users()
+ {
+ return $this->hasMany(SocialProviderUser::class, 'social_provider_id');
+ }
+
+ public function scopeActive(Builder $query): void
+ {
+ $query->where('active', 1);
+ }
+}
diff --git a/src/Models/SocialProviderUser.php b/src/Models/SocialProviderUser.php
new file mode 100644
index 0000000..6397f0e
--- /dev/null
+++ b/src/Models/SocialProviderUser.php
@@ -0,0 +1,42 @@
+ 'datetime',
+ 'provider_specific_data' => 'array'
+ ];
+
+ // Define a relationship to the User model
+ public function user()
+ {
+ return $this->belongsTo(User::class, 'user_id');
+ }
+
+ // Define a relationship to the SocialProvider model
+ public function socialProvider()
+ {
+ return $this->belongsTo(SocialProvider::class, 'social_provider_id');
+ }
+}
diff --git a/src/Traits/HasSocialProviders.php b/src/Traits/HasSocialProviders.php
new file mode 100644
index 0000000..8a2f7cb
--- /dev/null
+++ b/src/Traits/HasSocialProviders.php
@@ -0,0 +1,69 @@
+hasMany(SocialProviderUser::class);
+ }
+
+ /**
+ * Retrieve a list of social providers linked to the user.
+ */
+ public function getLinkedSocialProvidersAttribute()
+ {
+ return $this->socialProviders->map(function ($providerUser) {
+ return $providerUser->socialProvider;
+ });
+ }
+
+ /**
+ * Get social provider user data for a specific provider.
+ *
+ * @param string $providerName The name of the social provider.
+ * @return SocialProviderUser|null
+ */
+ public function getSocialProviderUser($providerName)
+ {
+ return $this->socialProviders->firstWhere('socialProvider.name', $providerName);
+ }
+
+ /**
+ * Check if the user is linked to a specific social provider.
+ *
+ * @param string $providerName The name of the social provider.
+ * @return bool
+ */
+ public function hasSocialProvider($providerName)
+ {
+ return $this->getSocialProviderUser($providerName) !== null;
+ }
+
+ /**
+ * Add or update social provider user information for a given provider.
+ *
+ * @param string $providerName The name of the social provider.
+ * @param array $data Data to store/update for the provider.
+ * @return SocialProviderUser
+ */
+ public function addOrUpdateSocialProviderUser($providerName, array $data)
+ {
+ $providerUser = $this->getSocialProviderUser($providerName);
+
+ if ($providerUser) {
+ $providerUser->update($data);
+ } else {
+ $providerUser = new SocialProviderUser($data);
+ $this->socialProviders()->save($providerUser);
+ }
+
+ return $providerUser;
+ }
+}