rafaelg21's avatar

Problems with Mardown and foreach dynamic rows

Good afternoon everyone,

I have a problem with the dynamic rows to show information from a DB in a Markdown using the table component if I put a foreach to the rows after the titles do not generate the rows in the table but it shows the data with the ones with the character | in the mail, but removing the foreach if you generate the entire table. this is because?


@component('mail::table')
| Código    | Descripción   | Cantidad  |
|:------:   |:-----------   |:--------: |
@foreach($dtmov as $dt)   
| 00003     | Right-Aligned |        50 |
@endforeach 

0 likes
4 replies
mushood's avatar
mushood
Best Answer
Level 41

Hello @rafaelg21

i tried to reproduce your code, and was unable to do so

Did you forget to add "@endcomponent" at the end of your code?

Here is my test code:

@component('mail::table')
| Laravel       | Table         | Example  |
| ------------- |:-------------:| --------:|
| Col 2 is      | Centered      |       |
| Col 3 is      | Right-Aligned |       |
@endcomponent

@component('mail::table')
| Código    | Descripción   | Cantidad  |
|:------:   |:-----------   |:--------: |
@foreach([1,2,3] as $dt)
| 00003     | Right-Aligned |        50 |
@endforeach
@endcomponent
1 like
rafaelg21's avatar

Thank you very much @mushood, I think that was the problem and the problem was solved.

@component('mail::table')
| Código    | Descripción   | Cantidad  |
|:------:   |:-----------   |:--------: |
@foreach($dtmov as $dt)
| {{$dt->cod_product}}     | {{$dt->name_product}} |        {{$dt->qty}} |
@endforeach
@endcomponent

1 like
bhatt_nishant's avatar

Do you know any class\method which create markdown format from database collection to markdown ?

Please or to participate in this conversation.