I have the a controller that calls a Mail class that fetches a view to be sent to an email. I was able to successfully retrieve a single view. But how do I concat multiple views together?
My controller:
namespace App\Http\Controllers;
class TestController extends Controller
{
public function sendMail(){
$notification = new NotificationService();
$notification->sendMail();
}
}
Service:
namespace App\Services;
use App\Mail\Test;
use Illuminate\Support\Facades\Mail;
class NotificationService
{
public function sendMail(){
Mail::to(['test@email.com'])->send(new Test);
}
}
Mail:
namespace App\Mail;
use Illuminate\Mail\Mailable;
class Test extends Mailable
{
public function build()
{
$view = $this->getTestView();
return $view;
}
private function getTestView(){
return $this->view(['TestEmail']);
}
}
I need to be able to put together multiple views in the Mail Test Class:
EG:
namespace App\Mail;
use Illuminate\Mail\Mailable;
class Test extends Mailable
{
public function build()
{
$view = $this->getTestView();
$view2 = $this->getTestView2()
return $view . $view2;
}
private function getTestView(){
return $this->view(['TestEmail']);
}
// HOW DO I CALL THIS IN THE build()?
private function getTestView2(){
return $this->view(['TestEmail2']);
}
}
Just make a new view that includes both
FullEmail.blade.php
@include('TestEmail')
@include('TestEmail2')