PHPackages                             spatie/laravel-welcome-notification - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. spatie/laravel-welcome-notification

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

spatie/laravel-welcome-notification
===================================

Send a welcome notification to new users

2.5.0(4mo ago)596761.4k↓14.8%467MITPHPPHP ^7.3|^8.0CI passing

Since Nov 12Pushed 1mo ago10 watchersCompare

[ Source](https://github.com/spatie/laravel-welcome-notification)[ Packagist](https://packagist.org/packages/spatie/laravel-welcome-notification)[ Docs](https://github.com/spatie/laravel-welcome-notification)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-laravel-welcome-notification/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (8)Versions (29)Used By (7)

Send a welcome notification to new users
========================================

[](#send-a-welcome-notification-to-new-users)

[![Latest Version on Packagist](https://camo.githubusercontent.com/53fa66bfdc982c7048495662e4a41d055b0e48547a12086a8132edfd7d98ef6a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d77656c636f6d652d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-welcome-notification)[![GitHub Workflow Status](https://github.com/spatie/laravel-welcome-notification/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-welcome-notification/actions/workflows/run-tests.yml/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/977222fd63ebf8a45ab545ef074bac66674cacd61bc39dfe280a907300bb3287/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d77656c636f6d652d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-welcome-notification)

Using this package you can send a `WelcomeNotification` to a new user of your app. The notification contains a secure link to a screen where the user can set an initial password.

```
$expiresAt = now()->addDay();

$user->sendWelcomeNotification($expiresAt);
```

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/862ae9f05d87b399dc0addca41b2c2d6725852c2792de61234b64885e264024d/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d77656c636f6d652d6e6f74696669636174696f6e2e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-welcome-notification)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-welcome-notification
```

### Migrating the database

[](#migrating-the-database)

You must publish the migrations provided by this package by executing this command:

```
php artisan vendor:publish --provider="Spatie\WelcomeNotification\WelcomeNotificationServiceProvider" --tag="migrations"
```

Next, you must migrate your database.

```
php artisan migrate
```

### Preparing the user model

[](#preparing-the-user-model)

You must apply the `\Spatie\WelcomeNotification\ReceivesWelcomeNotification` trait to your `User` model.

### Preparing the WelcomeController

[](#preparing-the-welcomecontroller)

Next you'll need to create a controller of your own that will extend `Spatie\WelcomeNotification\WelcomeController`. This controller will be used to show the welcome form and to save the password set by a user.

```
namespace App\Http\Controllers\Auth;

use Spatie\WelcomeNotification\WelcomeController as BaseWelcomeController;

class MyWelcomeController extends BaseWelcomeController
{
}
```

### Registering the routes

[](#registering-the-routes)

You'll have to register these routes:

```
use Spatie\WelcomeNotification\WelcomesNewUsers;
use App\Http\Controllers\Auth\MyWelcomeController;

Route::group(['middleware' => ['web', WelcomesNewUsers::class,]], function () {
    Route::get('welcome/{user}', [MyWelcomeController::class, 'showWelcomeForm'])->name('welcome');
    Route::post('welcome/{user}', [MyWelcomeController::class, 'savePassword']);
});
```

### Preparing the welcome form view

[](#preparing-the-welcome-form-view)

The `welcome` view that ships with the package, will be rendered when somebody clicks the welcome link in the welcome notification mail. You should style this view yourself. You can publish the views with this command:

```
php artisan vendor:publish --provider="Spatie\WelcomeNotification\WelcomeNotificationServiceProvider" --tag="views"
```

Usage
-----

[](#usage)

Here's how you can send a welcome notification to a user that you just created.

```
$expiresAt = now()->addDay();

$user->sendWelcomeNotification($expiresAt);
```

Handling successful requests
----------------------------

[](#handling-successful-requests)

After the a user has successfully set a new password the `sendPasswordSavedResponse` of the `WelcomeController` will get called.

```
use Symfony\Component\HttpFoundation\Response;

class MyWelcomeController extends BaseWelcomeController
{
    public function sendPasswordSavedResponse(): Response

    {
        return redirect()->route('home');
    }
}
```

Customizing the notification
----------------------------

[](#customizing-the-notification)

By default the `WelcomeNotification` will send a mail. If you wish to customize the mail you can extend `WelcomeNotification` and override the `buildWelcomeNotificationMessage` method.

```
use Illuminate\Notifications\Messages\MailMessage;

class MyCustomWelcomeNotification extends WelcomeNotification
{
    public function buildWelcomeNotificationMessage(): MailMessage
    {
        return (new MailMessage)
            ->subject('Welcome to my app')
            ->action(Lang::get('Set initial password'), $this->showWelcomeFormUrl);
    }
}
```

To use the custom notification you must add a method called `sendWelcomeNotification` to your `User` model.

```
public function sendWelcomeNotification(\Carbon\Carbon $validUntil)
{
    $this->notify(new MyCustomWelcomeNotification($validUntil));
}
```

Validating extra fields
-----------------------

[](#validating-extra-fields)

The default welcome form that ships with this package only asks for a password. You can add more fields to the form by [publishing the view](https://github.com/spatie/laravel-welcome-notification#preparing-the-welcome-form-view) and adding more fields to it.

To validate new fields you can override the `rules` function in your own `WelcomeController`. Here's an example where we want to validate an extra field named `job_title`.

```
class MyWelcomeController extends BaseWelcomeController
{
    public function rules()
    {
        return [
            'password' => 'required|confirmed|min:6',
            'job_title' => 'required',
        ];
    }
}
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

### Security

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

67

—

FairBetter than 99% of packages

Maintenance86

Actively maintained with recent releases

Popularity60

Solid adoption and visibility

Community38

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 60.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~88 days

Recently: every ~179 days

Total

27

Last Release

131d ago

Major Versions

0.0.6 → 1.0.02019-11-15

1.0.2 → 2.0.02020-03-09

PHP version history (2 changes)0.0.1PHP ^7.3

2.1.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (92 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (6 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (6 commits)")[![alexmanase](https://avatars.githubusercontent.com/u/10696975?v=4)](https://github.com/alexmanase "alexmanase (6 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (3 commits)")[![ainesophaur](https://avatars.githubusercontent.com/u/4686198?v=4)](https://github.com/ainesophaur "ainesophaur (3 commits)")[![lloydowen](https://avatars.githubusercontent.com/u/38921542?v=4)](https://github.com/lloydowen "lloydowen (3 commits)")[![ziming](https://avatars.githubusercontent.com/u/679513?v=4)](https://github.com/ziming "ziming (2 commits)")[![jartaud](https://avatars.githubusercontent.com/u/266818?v=4)](https://github.com/jartaud "jartaud (2 commits)")[![JeffreyHosler](https://avatars.githubusercontent.com/u/19713544?v=4)](https://github.com/JeffreyHosler "JeffreyHosler (2 commits)")[![moisesh18](https://avatars.githubusercontent.com/u/31388995?v=4)](https://github.com/moisesh18 "moisesh18 (2 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (2 commits)")[![Lloople](https://avatars.githubusercontent.com/u/5665466?v=4)](https://github.com/Lloople "Lloople (1 commits)")[![cochondeguerre](https://avatars.githubusercontent.com/u/272151221?v=4)](https://github.com/cochondeguerre "cochondeguerre (1 commits)")[![marventhieme](https://avatars.githubusercontent.com/u/53627227?v=4)](https://github.com/marventhieme "marventhieme (1 commits)")[![xseguib](https://avatars.githubusercontent.com/u/11737272?v=4)](https://github.com/xseguib "xseguib (1 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (1 commits)")[![Okipa](https://avatars.githubusercontent.com/u/5328934?v=4)](https://github.com/Okipa "Okipa (1 commits)")[![papamarfo](https://avatars.githubusercontent.com/u/6436250?v=4)](https://github.com/papamarfo "papamarfo (1 commits)")

---

Tags

authlaravelmailonboardingpasswordsecuritywelcomespatielaravel-welcome-mail

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/spatie-laravel-welcome-notification/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-welcome-notification/health.svg)](https://phpackages.com/packages/spatie-laravel-welcome-notification)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[beyondcode/laravel-confirm-email

Add email verification to your Laravel projects.

55357.0k](/packages/beyondcode-laravel-confirm-email)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
