splendidkeen
1 year ago

Request session() in Job (Exception: call to undefined method session())

Posted 1 year ago by splendidkeen

Hey, I am trying to send a Mail, based on the sessions language value.

SendMailJob


public function handle()
    {
        $email = new HelloMail($this->user);
 
        if ($this->session()->has('lang') == 'en') {
            $language = 'en';
        } elseif ($this->session()->has('lang') == 'de') {
            $language = 'de';
        } else {
            $language = 'en';
        }

        Mail::to($this->user->email)->locale($language)->send($email);
    }

I am running into Call to undefined method HelloMail::session()

Any suggestions how to get the session()->has('lang') attribute?

Thank you

Please sign in or create an account to participate in this conversation.