karabinse/laravel-user-invitation

使用内置的PasswordBroker为Laravel实现用户邀请

1.1.3 2024-05-10 13:19 UTC

This package is auto-updated.

Last update: 2024-09-10 14:20:37 UTC


README

Latest Version on Packagist GitHub Tests Action Status

安装

您可以通过composer安装此包

composer require karabinse/laravel-user-invitation

您可以使用以下命令发布和运行迁移

php artisan vendor:publish --tag="laravel-user-invitation-migrations"
php artisan migrate

您可以使用以下命令发布配置文件

php artisan vendor:publish --tag="laravel-user-invitation-config"

这是已发布的配置文件的内容

return [
    'notification_class' => \Karabin\UserInvitation\Notifications\InvitationNotification::class,
    'notification_subject' => 'Registered account',
    'notification_text' => "You're receiving this message because someone has registered an account for you on ".config('app.name').'. Click the link below to complete the registration by choosing a password',
    'notification_action_text' => 'Complete registration',
    'route' => 'register-user.create',
    'users_registration' => [
        'provider' => 'users',
        'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
        'expire' => env('USER_INVITATION_EXPIRE', (60 * 24) * 7),
        'throttle' => 60,
    ],
];

用法

添加特性

<?php

namespace Karabin\UserInvitation\Tests\Fixtures;

//...
use Karabin\UserInvitation\Traits\Inviteable;

class User extends AuthUser
{
    use Inviteable, Notifiable;
}

这提供了访问两个函数的能力

<?php

$user->createTokenForRegistration() // Returns a token string

$user->sendInvitation() // Creates a token and sends a notification

测试

composer test

变更日志

请参阅CHANGELOG了解最近的变化详情。

贡献

请参阅CONTRIBUTING以了解详情。

安全漏洞

请查看我们的安全策略了解如何报告安全漏洞。

致谢

许可

MIT许可(MIT)。请参阅许可文件以获取更多信息。