Skip to content

Welcome mail #57

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

Merged
merged 10 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
QUEUE_CONNECTION=database
SESSION_DRIVER=database
SESSION_LIFETIME=120

Expand Down
21 changes: 21 additions & 0 deletions app/Console/Commands/SendWelcomeMailToUsers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Console\Commands;

use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;

class SendWelcomeMailToUsers extends Command
{
protected $signature = 'lcm:send-welcome-mails';

protected $description = 'Send mails to new registered users.';

public function handle(): void
{
foreach (User::all() as $user) {
Mail::to($user)->queue(new \App\Mail\Welcome($user));
}
}
}
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function schedule(Schedule $schedule)
{
// $schedule->command('media-library:delete-old-temporary-uploads')->daily();
$schedule->command('lcm:delete-old-unverified-users')->daily();
$schedule->command('lcm:post-article-to-twitter')->twiceDaily(12, 16);
$schedule->command('lcm:post-article-to-twitter')->everyFourHours();
$schedule->command('lcm:post-article-to-telegram')->everyFourHours();
$schedule->command('lcm:send-unverified-mails')->weeklyOn(1, '8:00');
$schedule->command('sitemap:generate')->daily();
Expand Down
6 changes: 5 additions & 1 deletion app/Listeners/SendNewReplyNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
use App\Events\ReplyWasCreated;
use App\Models\User;
use App\Notifications\NewReplyNotification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class SendNewReplyNotification
class SendNewReplyNotification implements ShouldQueue
{
use InteractsWithQueue;

public function handle(ReplyWasCreated $event)
{
/** @var \App\Models\Thread $thread */
Expand Down
28 changes: 28 additions & 0 deletions app/Listeners/SendWelcomeMailNotification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Listeners;

use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Mail;

class SendWelcomeMailNotification implements ShouldQueue
{
use InteractsWithQueue;

/**
* Handle the event.
*
* @param Registered $event
* @return void
*/
public function handle(Registered $event)
{
/** @var User $user */
$user = $event->user;

Mail::to($user)->queue(new \App\Mail\Welcome($user));
}
}
6 changes: 5 additions & 1 deletion app/Mail/NewReplyEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

use App\Models\Reply;
use App\Models\Subscribe;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;

class NewReplyEmail extends Mailable
class NewReplyEmail extends Mailable implements ShouldQueue
{
use Queueable;

/**
* Create a new message instance.
*
Expand Down
3 changes: 2 additions & 1 deletion app/Mail/SendMailToUnVerifiedUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SendMailToUnVerifiedUsers extends Mailable
class SendMailToUnVerifiedUsers extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;

Expand Down
30 changes: 30 additions & 0 deletions app/Mail/Welcome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Mail;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class Welcome extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;

public function __construct(public User $user)
{
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('arthur@laravel.cm', 'Arthur Monney')
->subject(__('Bienvenue sur Laravel Cameroun ✨'))
->markdown('emails.welcome');
}
}
3 changes: 2 additions & 1 deletion app/Notifications/NewCommentNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
use App\Models\Reply;
use App\Models\Subscribe;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class NewCommentNotification extends Notification
class NewCommentNotification extends Notification implements ShouldQueue
{
use Queueable;

Expand Down
3 changes: 2 additions & 1 deletion app/Notifications/NewReplyNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
use App\Models\Reply;
use App\Models\Subscribe;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class NewReplyNotification extends Notification
class NewReplyNotification extends Notification implements ShouldQueue
{
use Queueable;

Expand Down
3 changes: 2 additions & 1 deletion app/Notifications/SendApprovedArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use App\Models\Article;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class SendApprovedArticle extends Notification
class SendApprovedArticle extends Notification implements ShouldQueue
{
use Queueable;

Expand Down
6 changes: 5 additions & 1 deletion app/Notifications/YouWereMentioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
namespace App\Notifications;

use App\Models\Reply;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class YouWereMentioned extends Notification
class YouWereMentioned extends Notification implements ShouldQueue
{
use Queueable;

public function __construct(public Reply $reply)
{
}
Expand Down
2 changes: 2 additions & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Listeners\SendNewCommentNotification;
use App\Listeners\SendNewReplyNotification;
use App\Listeners\SendNewThreadNotification;
use App\Listeners\SendWelcomeMailNotification;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
Expand All @@ -26,6 +27,7 @@ class EventServiceProvider extends ServiceProvider
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
SendWelcomeMailNotification::class,
],
ReplyWasCreated::class => [
SendNewReplyNotification::class,
Expand Down
Loading