Introduction
How it works
use Inertia\Inertia;
use App\Models\Post;
class PostsController extends Controller
{
public function index()
{
$posts = Post::latest()->paginate(10);
return Inertia::render('Posts/Index', [
'posts' => $posts
]);
}
}Posts/Index.vue
<script setup>
const { posts } = defineProps({
posts: Object,
});
</script>
<template>
<div v-for="post in posts" :key="post">
{{ post.title }}
</div>
</template>Last updated