Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index()
- {
- $locale = Lang::locale();
- // $locale = Lang::getLocale();
- $articles = Article::withTranslations($locale)->get();
- return $articles;
- }
- <template>
- <div>
- <div v-for="article in articles" :key="article.articles">
- <div v-for="translation in article.translations">
- <h4>{{ translation.title }}</h4>
- {{ translation.subtitle }}
- {{ translation.content }}
- </div>
- </div>
- </div>
- </template>
- <script>
- import axios from 'axios'
- export default {
- layout: 'basic',
- data: function () {
- return {
- articles: []
- }
- },
- mounted() {
- var app = this;
- axios.get('/api/articles')
- .then(response => {
- // JSON responses are automatically parsed.
- this.articles = response.data
- })
- .catch(e => {
- this.errors.push(e)
- })
- }
- }
- </script>
Add Comment
Please, Sign In to add comment