laravel-mail-editor
laravel-mail-editor copied to clipboard
View data object/array
Seems that the view data can only handle indiviudal variables, not objects or arrays
Hi @robov, would it be possible to give more information and an example? Are these variables that are passed into the constructor of the Mailable class?
Well, I just face this and still don't have any solution to do for each inside the email template. Every time I use @foreach, I always get this error Facade\Ignition\Exceptions\ViewException: syntax error, unexpected '&' (View: ...). It looks like it couldn't render <p>@foreach ($products->products as $product)</p>, but it works on one data.
Well, I just face this and still don't have any solution to do for each inside the email template. Every time I use @foreach, I always get this error
Facade\Ignition\Exceptions\ViewException: syntax error, unexpected '&' (View: ...). It looks like it couldn't render<p>@foreach ($products->products as $product)</p>, but it works on one data.
Aaaaand that was my fault. So I just figured this out. Looks like it couldn't render $products->products on foreach as I mentioned above, and I assign the products obj to new variable in the Mailable. Like this
`
public $data;
public $products;
public function __construct(Request $data)
{
//
$products = json_decode($data->products);
// dd($products);
$this->data = $data;
$this->products = $products->products;
}
`
And you can use @foreach like usual on the mail template.
That's it. Idk if this is what you meant but I'm glad if I could help with this.
Well, I just face this and still don't have any solution to do for each inside the email template. Every time I use @foreach, I always get this error
Facade\Ignition\Exceptions\ViewException: syntax error, unexpected '&' (View: ...). It looks like it couldn't render<p>@foreach ($products->products as $product)</p>, but it works on one data.
Hi @ridwankustanto just as a side note to what you had, the > should be filtered out in newer versions? Are you using the latest one?
@ridwankustanto but I am glad that is sorted now.
In line with the original issue, I do believe it is inline with what you had, so thank you for sharing the issue that you had.
With regards handling the arrays, I do believe that that should possibly be solved. But that would need some checks to confirm that.