Support the ongoing development of Laravel.io →
Views Blade Mail
Last updated 2 years ago.
0

Have you tried passing $alerts seperately with a ->with.

(other stuff being passed)->with('data2',$alerts);
Last updated 2 years ago.
0

hi jimgwhit, thanks for the reply.. yes i tried that too it works. the problem is that when you send the email alerts the data in the array is not there. passing it's elements as a variable they are visible but as an array it just doesn't work. the foreach loop in the email template just echoes a blank space!

0

Try iterating through array first and put the data in a string format like:

$mydata1 | $mydata2 | $mydata3

using pipe as seperator: Then use the explode function in php to place the data.
http://us.php.net/manual/en/function.explode.php
Another is split, but it's deprecated, but will still be around a while.

0

jimgwhit said:

Have you tried passing $alerts seperately with a ->with.

(other stuff being passed)->with('data2',$alerts);
~~~>**jimgwhit** said:

Try iterating through  array first and put the data in a string format like:  

$mydata1 | $mydata2 | $mydata3

using pipe as seperator:
Then use the explode function in php to place the data.  
http://us.php.net/manual/en/function.explode.php  
Another is split, but it's deprecated, but will still be around a while.
0

that works neat trick imploding and exploding the array...

thanks much

0

dtmuturi said:

that works neat trick imploding and exploding the array...

thanks much>dtmuturi said:

this should be the answer marked the wrong one

0

also found out changing the array element keys from objects to old school boxy braces works like so

<?php
					if(count(($alerts))
					{
						 Hi your accounts expire on
						 foreach(($alerts as $key)
						{
							echo '<li> #' .  $key['due_date'] . 'outstanding balance is '. $key['amount'] . ' </li>';				
						}
					}
					else
					{
						echo 'no alerts';
						
					}
				?>

instead of

@if(count($alerts))
                Hi your accounts expire on
                @foreach ($alerts as $key)
                    {{ $key->due_date }} outstanding balance is {{ $key->amount }}
                @endforeach
            @else
                <p>No alerts</p> 
            @endif
Last updated 9 years ago.
0

thanks much jimgwhit. coffee on me. :-)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

dtmuturi dtmuturi Joined 6 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.