Coder Social home page Coder Social logo

laravel-typegen's Issues

feat: support generate types via sail and outside of docker container

Summary

When generating, utilize sail artisan instead of php artisan outside of the Sail container to echo model JSON. Within the Docker container, we can invoke php artisan model:show if Sail is being used. However, outside the Docker container, calling artisan model:show via PHP is not possible; we need to use sail.

Could I try this issue? If it's ok, I will create PR.

Solution

  • add sail option
  • if sail option is enabled, use sail artisan instead of php artisan

Option to use objects instead of enums

use

export const GenderType = {
    Male: "Male",
    Female: "Female",
    Other: "Other"
} as const

instead of

export enum GenderType {
    Male = "Male",
    Female = "Female",
    Other = "Other"
}

Error on running npm run typegen

Hey hey, this is personal project I haven't touch for a while, and now I'm getting this error when trying to run the command. Any idea what could be happening?
image

Generate the props type for a Page from a Controller action

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>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.