Guest User

Untitled

a guest
Mar 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. public function index()
  2. {
  3. $locale = Lang::locale();
  4. // $locale = Lang::getLocale();
  5. $articles = Article::withTranslations($locale)->get();
  6. return $articles;
  7. }
  8.  
  9. <template>
  10. <div>
  11. <div v-for="article in articles" :key="article.articles">
  12. <div v-for="translation in article.translations">
  13. <h4>{{ translation.title }}</h4>
  14. {{ translation.subtitle }}
  15. {{ translation.content }}
  16. </div>
  17. </div>
  18. </div>
  19. </template>
  20.  
  21. <script>
  22. import axios from 'axios'
  23.  
  24. export default {
  25. layout: 'basic',
  26.  
  27. data: function () {
  28. return {
  29. articles: []
  30. }
  31. },
  32. mounted() {
  33. var app = this;
  34. axios.get('/api/articles')
  35. .then(response => {
  36. // JSON responses are automatically parsed.
  37. this.articles = response.data
  38. })
  39. .catch(e => {
  40. this.errors.push(e)
  41. })
  42. }
  43. }
  44. </script>
Add Comment
Please, Sign In to add comment