Skip to content

Commit

Permalink
revert readme format
Browse files Browse the repository at this point in the history
  • Loading branch information
nurdism committed Mar 7, 2023
1 parent 3eb2dec commit 3912791
Showing 1 changed file with 54 additions and 62 deletions.
116 changes: 54 additions & 62 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<User>
export type Users = Array<User>;

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<Team>
export type Teams = Array<Team>;
```

### What does this do?
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
```

Expand Down Expand Up @@ -148,8 +148,8 @@ And it should generate:

```ts
export interface Location {
// columns
choices: 'good' | 'bad'
// columns
choices: "good" | "bad";
}
```

Expand All @@ -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";
// ...
}
```

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
```
Expand Down Expand Up @@ -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';
}
```
Expand Down

0 comments on commit 3912791

Please sign in to comment.