Answer the question
In order to leave comments, you need to log in
Why does laravel get data from the database if I loaded it into an array?
Hello.
Please tell me how to improve it.
I get a list of words with translations from a database. It turns out that all data from the database is loaded into the $myWords array .
$myWords = Word::with('translations')
->where('lang_id', $text_lang_id)
->whereHas('translations', function (Builder $query) use ($translate_to_lang_id) {
$query->where('lang_id', '=', $translate_to_lang_id);
})->get();
$word = $myWords->where('word', $wordKey)->first();
$word->translations()->where('lang_id',$translateToLangId)->where('word_id', $word->id)->first()->translation;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question