PHP code example of spatie / laravel-welcome-notification
1. Go to this page and download the library: Download spatie/laravel-welcome-notification library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spatie / laravel-welcome-notification example snippets
namespace App\Http\Controllers\Auth;
use Spatie\WelcomeNotification\WelcomeController as BaseWelcomeController;
class MyWelcomeController extends BaseWelcomeController
{
}
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']);
});
use Symfony\Component\HttpFoundation\Response;
class MyWelcomeController extends BaseWelcomeController
{
public function sendPasswordSavedResponse(): Response
{
return redirect()->route('home');
}
}
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);
}
}
public function sendWelcomeNotification(\Carbon\Carbon $validUntil)
{
$this->notify(new MyCustomWelcomeNotification($validUntil));
}
class MyWelcomeController extends BaseWelcomeController
{
public function rules()
{
return [
'password' => '