تماشای این درس نیاز به اشتراک حرفه‌ای دارد.

Switching to Markdown Tables0:00

So, like I mentioned in the previous video, we can also use Markdown to render our table. So, I've gone ahead and I've deleted the contents of our orderConfirmationEmail file. So, I already wrote this Markdown up front, so you don't have to watch me write this line by line. So, let's take a look and review what we've got. So, as you can see, the start of our email looks very similar, but the table has been replaced by a component. This is a component that ships with Laravel itself, and as you can see, we're using a Markdown syntax to render the table. So, we've got our columns, and we're having a foreach loop to go through each of the items, and at the bottom, we have listed a couple of the prices, like shipping, discount, tax, and the total amount.

Fixing Table Indentation0:42

So, we've got our columns, and we're having a foreach loop to go through each of the items, and at the bottom, we have listed a couple of the prices, like shipping, discount, tax, and the total amount. Now, when we switch to browser, you can see that this is still a bit off. It's rendering our div for the class Table. It probably has to do with the indentation. When I pasted in this code, it applied these indents automatically. So, if we move everything back to the start of the file, you can see that the table is now rendering correctly, and it looks pretty good. So, this is how it looks like. You can also use this syntax if you like.

Customizing Markdown Table Syntax1:14

So, this is how it looks like. You can also use this syntax if you like. So, basically, you can draw out a table just like this. You can use columns to define whether something should be centered in the middle, to the left, or to the right. If you want to customize this component, you can also publish the views and make any changes. So, yeah, both options work. You can generate a table using HTML, or you can use something like Markdown. Just to show you, for example, I've defined all the different headers here for our table. Next, I'm looping through each of the items, providing the name, the description, the price, the quantity, the text, and the amount total. You can use HTML, by the way.

Adding Formatting and Conditionals1:49

Next, I'm looping through each of the items, providing the name, the description, the price, the quantity, the text, and the amountTotal. You can use HTML, by the way. So, I'm using a line break to make sure that the description is below the title. And you can use the double asterisks to make an item bold. And finally, we have a couple of if statements that checks whether amountShipping, amountDiscount, or text is a positive amount. And if it is, we'll show it in this case. Let's fix this alignment. So, this is an alternative approach where Laravel takes care of filing items for you, and you can use Markdown and these existing components to make it easier and quicker to scaffold out emails. It's pretty neat.

Choosing Markdown vs HTML2:25

and you can use Markdown and these existing components to make it easier and quicker to scaffold out emails. It's pretty neat. But feel free to choose whatever you want. You might want to be more flexible and have more options to modify how the email looks like. In that case, simply write your own HTML or Blade views and make the necessary changes.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟