I have a mailable created for sending out a bulk email, and part of the email is a button that contains a signed link used to confirm attendance at a class. I'm using the public properties in the mailable class to pass in the variable values to the template:
public String $confirm_url;
public function __construct(Carbon $class_date, Carbon $next_class_date, User $user)
{
$this->next_class_date = $next_class_date->format('l, F jS');
$this->day_number= $class_date->format('jS');
$this->day_name= $class_date->englishDayOfWeek;
$this->month= $class_date->month;
$this->full_date = $class_date->format('l, F jS, Y');
$this->picture_date = $class_date->subDays(2)->format('F jS');
$this->confirm_url = URL::temporarySignedRoute('application.class.confirm', now()->addWeeks(2), ['user' => $user->id]);
}
This works great for every variable except $confirm_url. When I pass in the URL like this:
<x-mail::button :url="{{ $confirm_url }}">
Confirm Attendance
</x-mail::button>
where the url is
http://mysite/application/confirm/2020?expires=1701231332&signature=71508ff58a2ef3b5d3d977a1bc87e0f0a5d65befec1f59d4f7446910a59db6c9
I get this error
syntax error, unexpected token "<" (View: /Users/steve/Sites/laravel/members/resources/views/mail/orientation-class.blade.php)
at storage/framework/views/ee13e55a8faf55a2c045cd56bfb754962165155b.php:45
where the line in error in the compiled view is
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => $__env->getContainer()->make(Illuminate\View\Factory::class)->make('mail::button'),'data' => ['url' => <?php echo e($confirm_url); ?>]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
where the <?php and $confirm_url are highlighted as being in error and the IDE message says the variable doesn't exist.
Am I passing the value in incorrectly?