Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Now that we have the working Post model,
we can finally save the submitted blog posts to the database.
I will first import the Post model in the Post controller file.
The Post model is inside of the App\Models directory.
And now I will scroll down to the store action because that is
where we actually need to store the blog post.
I don't want to store posts which don't pass validation,
so let's use this model after the validation code.
First, we need to create a new Post instance of the post model.
This will create a new empty post object and this is
exactly what we need because we need to create a new post
before we store it to the database.
I can now assign the user input from the request to the
post object properties of the same name.
These properties were dynamically created from the columns of the post table.
And now to actually save this new post instance to the database,
I can just use the save method.
Everything you do with model objects in the code will stay in
temporary memory until you actually use the save method to
commit the changes to the database.
And let me also modify this flash message.
Instead of getting the title and description from the request directly,
we'll get them from the post object itself.
Now let's test if all of this works as expected.
Open the Create Post page.
I will input some random title and description here.
Don't forget that description should be more than 10 characters long.
After I submit this, the post should be saved to the database.
There are no errors and this flash message looks correct so
hopefully everything worked as it should.
I will take a look at the posts table from the phpMyAdmin interface,
and here it is.
This is the blog post I submitted.
It is successfully saved to the database.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.