Multilingual Web Application with Laravel:
Handling multilingual models has never been easier.
There are a few ways of creating a multilingual database, which can be summarized to only two scenarios: build it yourself or use an existing package. Guess which one we will be doing in this tutorial :)
We will use this package dimsav/laravel-translatable for multilingual models. The readme in the package actually tells you how you need to write the migrations for your models for it to work correctly.
In the past, I have created my own way for multilingual models/database which worked, but after seeing this package and how it works, it just does not make any sense not to use it. It saves you so much time, as you will see in this tutorial, so let's get started.
We will create a model called
Article which will have fields
content. These fields need to be translatable to Croatian and English. This process will consist of us installing the package, writing migrations and setting up the model(s).
articles - id INT UNSIGNED - title VARCHAR - content TEXT NULLABLE - created_at DATETIME - updated_at DATETIME
To continue reading, choose a subscription plan: