Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate the props type for a Page from a Controller action #14

Open
7nohe opened this issue Apr 26, 2023 · 1 comment
Open

Generate the props type for a Page from a Controller action #14

7nohe opened this issue Apr 26, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@7nohe
Copy link
Owner

7nohe commented Apr 26, 2023

Let's assume we have a PostsController like the following in a Laravel project:

class PostsController extends Controller
{
    public function index()
    {
        $posts = Post::all();
        return Inertia::render(
            'Posts/Index',
            [
                'posts' => $posts
            ]
        );
    }
}

This code generates a props type called PostsIndexProps, which can be used as follows:

<script setup lang="ts">
import { PostsIndexProps } from '@/types/props';
const page = usePage<PostsIndexProps>()
</script>
@7nohe 7nohe added the enhancement New feature or request label Apr 26, 2023
@prismosoft
Copy link

That would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants