PHPackages                             acelords/laravel-model-ts-type - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. acelords/laravel-model-ts-type

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

acelords/laravel-model-ts-type
==============================

This package makes it possible to generate TypeScript types based on your models

v1.0.1(1y ago)013MITPHPPHP ^8.1

Since Aug 24Pushed 1y agoCompare

[ Source](https://github.com/acelords/laravel-model-ts-type)[ Packagist](https://packagist.org/packages/acelords/laravel-model-ts-type)[ Docs](https://github.com/acelords/laravel-model-ts-type)[ RSS](/packages/acelords-laravel-model-ts-type/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

laravel-model-ts-type
=====================

[](#laravel-model-ts-type)

Generate TypeScript types based on your models.

Usage
-----

[](#usage)

### Installation

[](#installation)

Install the package using composer:

```
composer require --dev scrumble-nl/laravel-model-ts-type

```

### Generating types

[](#generating-types)

```
php artisan types:generate {--modelDir=} {--outputDir=} {--model=} {--noKebabCase}

```

Additional options:

OptionDefault valueDescription`modelDir``app/Models`The root directory where the package can find all Laravel models`outputDir``resources/js/models`The root directory for outputting the `.d.ts` files`namespace``false`The namespace of the generated Types. Use `false` if you don't prefer to have one`noKebabCase``false`Whether the file name should be formatted to kebab case`model``null`Choose to generate a model for a specific file. For example you can use `App\Models\User``indentationSpaces``4`The amount of spaces used for indentation`export_types``true`Whether to export the types or not.If you want to change the default values you can publish the config file and change it to you liking.

NOTE: Do not forget to add the directory to your typeroots in `tsconfig.json`

### What does it do?

[](#what-does-it-do)

This package takes (almost) all off Laravel's magic into account. It follows these steps for generating a Type:

1. Retrieve all fields from te database (only MySQL/MariaDB supported) and map them to default types (string, number, etc.)
2. Add relations for the Model, they will point to the related generated Type
3. Add the attribute getters for the Model
4. Check the `casts` attribute
5. Remove all fields that are in the `hidden` attribute

### Example output

[](#example-output)

```
export type Company = {
    id: number;
    name: string;
    created_at: string /* Date */ | null;
    updated_at: string /* Date */ | null;
    slug: string;
    welcome_message: string | null;
    contact_information: string | null;
    main_color: string | null;
    logo_src: string | null;
    user_field: any[];
    language: any[];
    team_site: any[];
    is_api_enabled: boolean;
    kaizen_user_field: string;
    faqs?: Faq[] | null;
    users?: User[] | null;
    team_properties: TeamProperty[] | null;
    editor_images: EditorImage[] | null;
    meta_data?: any[];
};
```

Roadmap
-------

[](#roadmap)

- Add tests (in progress)
- Generate types for packagized models
- Create command to generate type for 1 model
- Implement unqualified name for relation doc blocks

Contributing
------------

[](#contributing)

If you would like to see additions/changes to this package you are always welcome to add some code or improve it.

Scrumble
--------

[](#scrumble)

This product has been originally developed by [Scrumble](https://www.scrumble.nl) for internal use. As we have been using lots of open source packages we wanted to give back to the community. We hope this helps you getting forward as much as other people helped us!

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

679d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9af2de9860484f10b831cb96b650b5d8ac59a6f826589cbade7ee23828d4aa90?d=identicon)[SyntaxLexx](/maintainers/SyntaxLexx)

---

Top Contributors

[![Luukdewaaier](https://avatars.githubusercontent.com/u/54863704?v=4)](https://github.com/Luukdewaaier "Luukdewaaier (84 commits)")[![jaulz](https://avatars.githubusercontent.com/u/5358638?v=4)](https://github.com/jaulz "jaulz (15 commits)")[![RicoClark](https://avatars.githubusercontent.com/u/54905956?v=4)](https://github.com/RicoClark "RicoClark (14 commits)")[![syntaxlexx](https://avatars.githubusercontent.com/u/19994360?v=4)](https://github.com/syntaxlexx "syntaxlexx (4 commits)")[![stefanScrumble](https://avatars.githubusercontent.com/u/89080949?v=4)](https://github.com/stefanScrumble "stefanScrumble (4 commits)")[![OliverBeckwith](https://avatars.githubusercontent.com/u/23747711?v=4)](https://github.com/OliverBeckwith "OliverBeckwith (4 commits)")[![beamdotdev](https://avatars.githubusercontent.com/u/56007474?v=4)](https://github.com/beamdotdev "beamdotdev (3 commits)")[![ConnorMoodyDev](https://avatars.githubusercontent.com/u/56007474?v=4)](https://github.com/ConnorMoodyDev "ConnorMoodyDev (3 commits)")[![tekord](https://avatars.githubusercontent.com/u/1286100?v=4)](https://github.com/tekord "tekord (3 commits)")[![thekonz](https://avatars.githubusercontent.com/u/2700089?v=4)](https://github.com/thekonz "thekonz (2 commits)")[![sefirosweb](https://avatars.githubusercontent.com/u/20754836?v=4)](https://github.com/sefirosweb "sefirosweb (2 commits)")

---

Tags

typemodeltypescriptcommandgenerate

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/acelords-laravel-model-ts-type/health.svg)

```
[![Health](https://phpackages.com/badges/acelords-laravel-model-ts-type/health.svg)](https://phpackages.com/packages/acelords-laravel-model-ts-type)
```

###  Alternatives

[scrumble-nl/laravel-model-ts-type

This package makes it possible to generate TypeScript types based on your models

6989.0k](/packages/scrumble-nl-laravel-model-ts-type)[scrumble-nl/laravel-csr

This package makes it possible to generate a controller, service, repository, model and migration all in 1 command

4320.4k](/packages/scrumble-nl-laravel-csr)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
