title: Laravel - a good way to get db data depending on language
body: <p>I'm programming a backend in which the admin can edit different texts for the frontend. </p>
  
  <p>The website has about 20-30 different text passages and these are to be displayed in the respective language, depending on whether the user selects English or German in the frontend. </p>
  
  <p>For different text languages I usually used the Laravel language packs. However, since the data is to be changed in the backend, I have to dynamically get the data from the database, depending on the selected language.</p>
  
  <p>Now I'm looking for a good way to get the right data from the database without having to make a database query for each text passage. </p>
  
  <p>Database dummy data looks like this: </p>
  
  <p><a href="https://i.stack.imgur.com/NSeoE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NSeoE.png" alt="enter image description here"></a></p>
  
  <p>With this code: </p>
  
  <pre><code>$helloText = Texts::where(
              'title', 'hello')-&gt;where(
              'code', Config::get('app.locale'))-&gt;first();
  $aboutText = Texts::where(
              'title', 'about')-&gt;where(
              'code', Config::get('app.locale'))-&gt;first();
  </code></pre>
  
  <p>These 2 requests are for 2 text passages. I would have to do the same for 20-30 other text passages at the moment. I wanted to ask if there would be a better way to summarize them all in one query by specifying all the "titles" I need for this blade. </p>
  
  <p>Or maybe another way. There need's to be another way to do that, without allways doing 20-30 querys. At least I hope for another way. </p>
  
  <p>And if someone know's a better way, I would love to see how I output the correct data in the correct place in the view. Because I haven't found a better way right now.. </p>
  
  <p>Thanks for your help!</p>