Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

laravelstart/laravelstart

20 stars
3 code files
View laravelstart/laravelstart on GitHub

app/Mail/NewStarterKitMail.php

Open in GitHub
use App\Models\StarterKit;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
 
class NewStarterKitMail extends Mailable
{
use Queueable, SerializesModels;
 
public function __construct(
private readonly StarterKit $kit,
private readonly User $user
)
{
}
 
public function envelope(): Envelope
{
return new Envelope(
subject: "{$this->kit->title} is out!",
);
}
 
public function content(): Content
{
return new Content(
markdown: 'mail.new-kit-mail',
with: [
'kit' => $this->kit,
'user' => $this->user,
]
);
}
}

resources/views/mail/new-kit-mail.blade.php

Open in GitHub
<x-mail::message>
# New Starter Kit Available! 🚀
 
Hey **{{ "@$user->name" }}** 👋
 
We're excited to announce that a new starter kit "{{ $kit->title }}" is now available on {{ config('app.name') }}!
 
You can try it out right now:
* [Check out {{ $kit->title }}]({{ url('/kits/' . $kit->slug) }})
* Create a new Laravel project using this starter kit
* [Browse other starter kits]({{ url('/browse/official') }})
 
<x-mail::button :url="url('/kits/' . $kit->slug)" color="primary">
Try {{ $kit->title }}
</x-mail::button>
 
If you have any questions, feel free to reach out to [our support team](mailto:[email protected]). We're here to help!
 
Best regards,<br>
The {{ config('app.name') }} Team
</x-mail::message>

app/Console/Commands/NotifyAboutNewStarterKit.php

Open in GitHub
use App\Mail\NewStarterKitMail;
use App\Models\StarterKit;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
 
class NotifyAboutNewStarterKit extends Command
{
// ...
 
public function handle(): int
{
$kit = StarterKit::query()->findOrFail($this->argument('kitId'));
 
User::all()->each(function (User $user) use ($kit) {
Mail::to($user)->send(new NewStarterKitMail($kit, $user));
});
 
return 0;
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.