From 3912791080cdc5e5c5126c3794c97dad6ad66897 Mon Sep 17 00:00:00 2001 From: nurdism Date: Tue, 7 Mar 2023 01:52:10 +0000 Subject: [PATCH] revert readme format --- readme.md | 116 +++++++++++++++++++++++++----------------------------- 1 file changed, 54 insertions(+), 62 deletions(-) diff --git a/readme.md b/readme.md index cfbf9e7..c5a51f6 100644 --- a/readme.md +++ b/readme.md @@ -20,35 +20,35 @@ will output ```ts export interface User { - // columns - id: number - email: string - name: string - created_at?: Date - updated_at?: Date - // mutators - first_name: string - initials: string - // relations - teams: Teams + // columns + id: number; + email: string; + name: string; + created_at?: Date; + updated_at?: Date; + // mutators + first_name: string; + initials: string; + // relations + teams: Teams; } -export type Users = Array +export type Users = Array; export interface Team { - // columns - id: number - name: string - logo: string - created_at?: Date - updated_at?: Date - // mutators - initials: string - slug: string - url: string - // relations - users: Users + // columns + id: number; + name: string; + logo: string; + created_at?: Date; + updated_at?: Date; + // mutators + initials: string; + slug: string; + url: string; + // relations + users: Users; } -export type Teams = Array +export type Teams = Array; ``` ### What does this do? @@ -61,11 +61,11 @@ Starting support is for Laravel v9.21+ and PHP v8.1+ > **Note** > This package may require you to install Doctrine DBAL. If so you can run - ```bash composer require doctrine/dbal ``` + 1. You must have a [return type](https://www.php.net/manual/en/language.types.declarations.php) for your model relationships ```php @@ -112,11 +112,11 @@ public array $interfaces = [ And it should generate: ```ts -import { Point } from '@/types/api' +import { Point } from "@/types/api"; export interface Location { - // columns - coordinate: Point + // columns + coordinate: Point; } ``` @@ -148,8 +148,8 @@ And it should generate: ```ts export interface Location { - // columns - choices: 'good' | 'bad' + // columns + choices: "good" | "bad"; } ``` @@ -169,10 +169,10 @@ This will generate: ```ts export interface Location { - // ... - // overrides - state: 'found' | 'not_found' | 'searching' | 'reset' - // ... + // ... + // overrides + state: "found" | "not_found" | "searching" | "reset"; + // ... } ``` @@ -202,14 +202,13 @@ declare global { ```bash artisan model:typer --plurals ``` - Exports for example, when a `User` model exists: ```ts export type Users = User[] ``` -### Output Api.MetApi\* resources +### Output Api.MetApi* resources ```bash artisan model:typer --api-resources @@ -218,18 +217,10 @@ artisan model:typer --api-resources Exports: ```ts -export interface UserResults extends api.MetApiResults { - data: Users -} -export interface UserResult extends api.MetApiResults { - data: User -} -export interface UserMetApiData extends api.MetApiData { - data: User -} -export interface UserResponse extends api.MetApiResponse { - data: UserMetApiData -} +export interface UserResults extends api.MetApiResults { data: Users } +export interface UserResult extends api.MetApiResults { data: User } +export interface UserMetApiData extends api.MetApiData { data: User } +export interface UserResponse extends api.MetApiResponse { data: UserMetApiData } ``` ### Enable all output options @@ -267,16 +258,16 @@ This will generate something like: ```ts export interface User { - // columns - id: number - email: string - name?: string - created_at?: Date - updated_at?: Date - // mutators - is_captain: boolean - // relations - teams: TeamUsers + // columns + id: number; + email: string; + name?: string; + created_at?: Date; + updated_at?: Date; + // mutators + is_captain: boolean; + // relations + teams: TeamUsers; } ``` @@ -311,9 +302,10 @@ namespace App\Enums; * @property ADMIN - Can do anything * @property USER - Standard read-only */ -enum UserRoleEnum: string { - case ADMIN = 'admin'; - case USER = 'user'; +enum UserRoleEnum: string +{ + case ADMIN = 'admin'; + case USER = 'user'; } ```