PHPackages                             nolanos/laravel-model-typescript-transfomer - 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. [Database &amp; ORM](/categories/database)
4. /
5. nolanos/laravel-model-typescript-transfomer

ActiveLibrary[Database &amp; ORM](/categories/database)

nolanos/laravel-model-typescript-transfomer
===========================================

Generate Typescript definitions for your Eloquent models

v1.3.0(1y ago)73.1k↓55.6%2[5 issues](https://github.com/nolanos/laravel-model-typescript-transfomer/issues)MITPHPPHP ^8.2CI failing

Since Sep 5Pushed 1y agoCompare

[ Source](https://github.com/nolanos/laravel-model-typescript-transfomer)[ Packagist](https://packagist.org/packages/nolanos/laravel-model-typescript-transfomer)[ Docs](https://github.com/nolanos/laravel-model-typescript-transfomer)[ GitHub Sponsors](https://github.com/sponsors/ncphillips)[ RSS](/packages/nolanos-laravel-model-typescript-transfomer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (6)Used By (0)

Laravel Model Typescript Transformer
====================================

[](#laravel-model-typescript-transformer)

This package generates TypeScript definitions for Laravel Eloquent models using [spatie/laravel-typescript-transformer](https://github.com/spatie/laravel-typescript-transformer).

Installation
------------

[](#installation)

Install via Composer:

```
composer require nolanos/laravel-model-typescript-transformer
```

Update your `config/typescript-transformer.php` config file by...

- Appending `ModelTypeScriptCollector` to the `collectors` array.
- Appending `ModelTransformer` to the `transformers` array.

```
    'collectors' => [
        // ...
        Nolanos\LaravelModelTypescriptTransformer\ModelTypeScriptCollector::class,
    ],
    'transformers' => [
        // Etc....
        Nolanos\LaravelModelTypescriptTransformer\ModelTransformer::class,
    ],
```

Usage
-----

[](#usage)

Generate TypeScript definitions by running:

```
php artisan typescript:generate
```

How it works
------------

[](#how-it-works)

### Identifying Properties

[](#identifying-properties)

The `ModelTransformer` identifies the properties of the given `Model` by looking at the columns in the database table, and then filters columns out based on the `$hidden` and `$visible` properties of the model.

### Mapping Database Types to TypeScript Types

[](#mapping-database-types-to-typescript-types)

Property types are determined by mapping the database column type to a TypeScript type. The following mappings are used:

Typescript TypeDatabase Typestringuuid, string, text, varchar, character varying, date, datetime, timestamp, timestamp without time zone, bpchar, timestamptz, time, bytea, blobnumberinteger, bigint, int2, int4, int8, float, double, decimal, float8, numericbooleanboolean, boolNote: Unknown column types will be mapped to `unknown` and are followed by a comment stating the db type.

### Nullable Types

[](#nullable-types)

If a column is nullable, the TypeScript type will be suffixed with `| null`.

Example
-------

[](#example)

Let's look at a simple of example of a user model in a PostgreSQL database.

```
CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL ,
    password VARCHAR(255),
    active BOOLEAN NOT NULL,
    created_at TIMESTAMP,
    updated_at TIMESTAMP
);
```

The `User` model might look like this:

```
class User extends Model
{
    protected $hidden = ['password'];
}
```

Will generate the following TypeScript definition:

```
declare namespace App.Models {
  export interface User {
    id: number
    name: string
    email: string
    active: boolean
    created_at: string | null
    updated_at: string | null
  }
}
```

Limitations
-----------

[](#limitations)

This package has some limitations.

Take a look at the [issues](https://github.com/nolanos/laravel-model-typescript-transfomer/issues) to see what's missing.

Development
===========

[](#development)

### Setup

[](#setup)

```
git clone git@github.com:nolanos/laravel-model-typescript-transfomer.git

cd laravel-model-typescript-transformer

composer install
```

### Running Tests

[](#running-tests)

```
composer test
```

### Publishing new Versions

[](#publishing-new-versions)

To publish a new version of the package, you need to create a new tag and push it to the repository.

```
git tag vx.x.x
git push origin vx.x.x
```

Go to [Packagist](https://packagist.org/packages/nolanos/laravel-model-typescript-transformer) and click on "Update" to update the package.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~43 days

Total

5

Last Release

441d ago

### Community

Maintainers

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

---

Top Contributors

[![ncphillips](https://avatars.githubusercontent.com/u/824015?v=4)](https://github.com/ncphillips "ncphillips (22 commits)")

---

Tags

laraveltypescripttypescript-trlaraveleloquenttypescript

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/nolanos-laravel-model-typescript-transfomer/health.svg)

```
[![Health](https://phpackages.com/badges/nolanos-laravel-model-typescript-transfomer/health.svg)](https://phpackages.com/packages/nolanos-laravel-model-typescript-transfomer)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[bavix/laravel-clickhouse

Eloquent model for ClickHouse

72214.1k2](/packages/bavix-laravel-clickhouse)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)[mozex/laravel-scout-bulk-actions

A Laravel Scout extension for bulk importing and flushing of all models.

1033.4k](/packages/mozex-laravel-scout-bulk-actions)

PHPackages © 2026

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