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
Laravel makes implementing authentication very simple. We will implement authentication in our existing application.
In this tutorial, we will cover creating, updating, deleting and viewing all multilingual articles.
We will create a new Laravel application which connects to the API that we have built in the previous lessons.
Learn how to implement JWT authentication in your Lumen application the proper way.