Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: allow socialite user model customization #72

Merged
merged 16 commits into from
Mar 1, 2024

Conversation

kykurniawan
Copy link
Contributor

Allow socialite user model customization by passing the model class to the plugin configuration.

Example:

Customize migration to using UUID as the primary key.

return new class extends Migration
{
    public function up()
    {
        Schema::create('socialite_users', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('user_id');
            $table->string('provider');
            $table->string('provider_id');

            $table->timestamps();
            $table->softDeletes();

            $table->unique([
                'provider',
                'provider_id',
            ]);
        });
    }

    public function down()
    {
        Schema::dropIfExists('socialite_users');
    }
};

Extend the sociallite user

class SocialiteUser extends ModelsSocialiteUser
{
    use HasUuids, SoftDeletes;
}

Pass the model class in the plugin configuration

$panel->plugin(
    FilamentSocialitePlugin::make()
        ->setSocialiteUserModelClass(SocialiteUser::class)
);

@bramr94 bramr94 added the enhancement New feature or request label Feb 20, 2024
src/FilamentSocialite.php Outdated Show resolved Hide resolved
src/Http/Controllers/SocialiteLoginController.php Outdated Show resolved Hide resolved
@bert-w bert-w merged commit 83f0e93 into DutchCodingCompany:main Mar 1, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants