Skip to content
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

Added missing code to set locale from model preferred locale #45308

Merged
merged 1 commit into from Dec 15, 2022

Conversation

clementbirkle
Copy link
Contributor

Hi,

According to the documentation, it's possible to set the locale from a model like that: https://laravel.com/docs/9.x/mail#user-preferred-locales

It works great if you use the method to via Illuminate\Support\Facades\Mail class like in this example: https://laravel.com/docs/9.x/mail#sending-mail

But if you want to do the same inside a lluminate\Mail\Mailable class, it will not set the locale. Like this example:

<?php
 
namespace App\Mail;
 
use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Queue\SerializesModels;
 
class OrderShipped extends Mailable
{
    use Queueable, SerializesModels;
 
    protected $order;
    protected $user;
 
    public function __construct(Order $order, User $user)
    {
        $this->to($user);
    }
}

This PR fix that.

@taylorotwell taylorotwell merged commit a670437 into laravel:9.x Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants