All language subtitles for 6.checking-for-empty-collection

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,440 --> 00:00:04,360 Before we wrap up this module, I want to implement one more thing 2 00:00:04,360 --> 00:00:09,410 here in the Home template. At the moment we have two posts in the 3 00:00:09,410 --> 00:00:12,320 database, but what if we had none? 4 00:00:12,600 --> 00:00:16,400 Let's test this scenario. Inside of the phpMyAdmin, 5 00:00:16,400 --> 00:00:20,150 I will remove both of the existing posts from the database. 6 00:00:20,540 --> 00:00:24,350 You can also do that in the command line or in whichever way you 7 00:00:24,350 --> 00:00:27,460 prefer, as long as the posts table is empty. 8 00:00:28,540 --> 00:00:32,380 If I refresh the Home page now, you can see that all we get is 9 00:00:32,380 --> 00:00:35,460 a blank page, which is kind of expected, 10 00:00:35,840 --> 00:00:39,260 but again, this is not really good user experience. 11 00:00:39,640 --> 00:00:44,060 We could of course add an if directive first to check if the post 12 00:00:44,060 --> 00:00:48,890 collection is empty before rendering this foreach loop, and there is 13 00:00:48,890 --> 00:00:51,970 nothing wrong with that approach. However, 14 00:00:51,980 --> 00:00:55,960 there is a better built‑in way to do this. Instead of using 15 00:00:55,960 --> 00:00:59,550 foreach, let's use the forelse directive. 16 00:00:59,750 --> 00:01:03,870 The functionality of these two directives is basically the same, 17 00:01:03,880 --> 00:01:06,960 but we get some additional features with forelse. 18 00:01:07,240 --> 00:01:11,780 We can add this empty directive inside of the forelse block 19 00:01:11,790 --> 00:01:15,050 to define what would happen if the variable that we are 20 00:01:15,050 --> 00:01:17,260 trying to loop over is empty. 21 00:01:17,540 --> 00:01:21,130 If that's the case, I will render a simple message. 22 00:01:21,370 --> 00:01:27,610 This empty directive works kind of like an else statement. And if I refresh the 23 00:01:27,610 --> 00:01:32,700 Home page now, you can see that instead of a blank page, we now get this useful 24 00:01:32,700 --> 00:01:35,680 message informing us that everything is fine, 25 00:01:35,680 --> 00:01:38,760 but there are no posts in the database yet. 26 00:01:39,140 --> 00:01:42,510 Maybe this doesn't seem like something important, but I think 27 00:01:42,510 --> 00:01:45,960 that you will often have the need to show something else in case 28 00:01:45,960 --> 00:01:48,120 that there is no data to display. 29 00:01:48,340 --> 00:01:52,160 If you have any questions, don't hesitate to post them in the discussion.2600

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.