Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
clementbirkle:set-locale-from-model
Dec 15, 2022
Merged

Added missing code to set locale from model preferred locale#45308
taylorotwell merged 1 commit into
laravel:9.xfrom
clementbirkle:set-locale-from-model

Conversation

@clementbirkle
Copy link
Copy Markdown
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.

2 participants