PHPackages                             scrumble-nl/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. scrumble-nl/laravel-model-ts-type

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

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

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

10.5.2(5mo ago)6984.5k—8.7%18[2 PRs](https://github.com/scrumble-nl/laravel-model-ts-type/pulls)MITPHPPHP ^8.1

Since Sep 28Pushed 5mo agoCompare

[ Source](https://github.com/scrumble-nl/laravel-model-ts-type)[ Packagist](https://packagist.org/packages/scrumble-nl/laravel-model-ts-type)[ Docs](https://github.com/scrumble-nl/laravel-model-ts-type)[ RSS](/packages/scrumble-nl-laravel-model-ts-type/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (26)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 indentationIf 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 the 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)

```
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

57

—

FairBetter than 98% of packages

Maintenance73

Regular maintenance activity

Popularity46

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 62.6% 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 ~86 days

Recently: every ~134 days

Total

23

Last Release

155d ago

Major Versions

8.1.0 → 9.0.02022-03-11

9.3.0 → 10.0.02023-02-15

PHP version history (3 changes)8.0PHP &gt;=7.3

9.0.0PHP &gt;=7.3|^8.0

9.2.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/6369f0cc890cf79d39d7179fc6c28a8a3ea4a86090fd6c8d3bbf34d46559be99?d=identicon)[luukdewaaier](/maintainers/luukdewaaier)

![](https://www.gravatar.com/avatar/a0d746a86e1d0d0b66e93e2ccdbab5b08931f5e5b93806ae183f3f3fc3c8ce57?d=identicon)[RicoClark](/maintainers/RicoClark)

---

Top Contributors

[![Luukdewaaier](https://avatars.githubusercontent.com/u/54863704?v=4)](https://github.com/Luukdewaaier "Luukdewaaier (92 commits)")[![RicoClark](https://avatars.githubusercontent.com/u/54905956?v=4)](https://github.com/RicoClark "RicoClark (15 commits)")[![jaulz](https://avatars.githubusercontent.com/u/5358638?v=4)](https://github.com/jaulz "jaulz (15 commits)")[![OliverBeckwith](https://avatars.githubusercontent.com/u/23747711?v=4)](https://github.com/OliverBeckwith "OliverBeckwith (4 commits)")[![stefanScrumble](https://avatars.githubusercontent.com/u/89080949?v=4)](https://github.com/stefanScrumble "stefanScrumble (4 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)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![sefirosweb](https://avatars.githubusercontent.com/u/20754836?v=4)](https://github.com/sefirosweb "sefirosweb (2 commits)")[![1RV34](https://avatars.githubusercontent.com/u/4242602?v=4)](https://github.com/1RV34 "1RV34 (1 commits)")[![simonostendorf](https://avatars.githubusercontent.com/u/70595012?v=4)](https://github.com/simonostendorf "simonostendorf (1 commits)")[![Mechazawa](https://avatars.githubusercontent.com/u/1144171?v=4)](https://github.com/Mechazawa "Mechazawa (1 commits)")[![Devin345458](https://avatars.githubusercontent.com/u/22183751?v=4)](https://github.com/Devin345458 "Devin345458 (1 commits)")[![Reddishye](https://avatars.githubusercontent.com/u/46359630?v=4)](https://github.com/Reddishye "Reddishye (1 commits)")

---

Tags

typemodeltypescriptcommandgenerate

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[gbrock/laravel-table

Table functionality for Laravel models

7644.3k](/packages/gbrock-laravel-table)[scrumble-nl/laravel-csr

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

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

PHPackages © 2026

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