Oh first question. What php version are you running :)
Nov 29, 2021
20
Level 14
->through not working with Laravel and Inertia
Hi, I'm trying to add pagination to my site and I did follow both Jeffrey's tutorial and checked the demo app from inertia. They both used ->through for mapping there result but still getting the pagination along. I have in my component that posts should be an Object
Has anyone what is wrong with my code? (PHPStorm is complaining that fn only works in PHP 7.4)
Here is my code:
return Inertia::render('Posts/Index', [
'filters' => Request::all('leita', 'flokkur', 'höfundur'),
'tags' => Tag::all(),
'posts' => Post::with(['tags', 'images'])
->orderBy('created_at')
->filter(Request::only('leita', 'flokkur', 'höfundur'))
->paginate(2)
->withQueryString()
->through(fn ($post) => [
'slug' => $post->slug,
'title' => $post->title,
'author' => $post->author,
'created_at' => $post->created_at,
'content' => $post->content,
'img_url' => $post->img_url,
'tags' => $post->tags,
'image' => $post->images[0]
])
]);
Level 102
@hjortur17 you are missing .data
<small-preview v-for="post in posts.data" :key="post.title" :post="post"></small-preview>
Please or to participate in this conversation.