Answer the question
In order to leave comments, you need to log in
How to do relationships in Laravel?
Good day.
There are tables users, codes, langs and themes.
I need to associate users with codes and codes with langs and themes.
In codes I do this:
$table->integer('lang_id')->unsigned();
$table->foreign('lang_id')->references('id')->on('langs');
$table->integer('theme_id')->unsigned();
$table->foreign('theme_id')->references('id')->on('themes');
$table->integer('lang_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
Answer the question
In order to leave comments, you need to log in
Here, read at your leisure:
Here, in very simple terms, it talks about relationships in Laravel Eloquent.
You should always use an ORM if there is one. In Lara's case, Eloquent should always be used. This greatly simplifies development and makes the code cleaner and more readable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question