# spatie/laravel-view-models

View models in Laravel

Repository: https://github.com/spatie/laravel-view-models
Canonical: https://ross.abutalabs.com/products/laravel-view-models
Homepage: https://spatie.be/open-source
Language: PHP
License: MIT
License Family: permissive
Topics: laravel, php, view, models
Last push: 2026-06-02T06:36:56+00:00

## Health v2 (maintenance only)
Score: 72/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 85, release rhythm 39, longevity 100
- inputs: {"age_days": 2917, "days_push": 92, "days_rel": 193, "gap_med": 372, "n_releases_24m": 2}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1090, forks 60 (observed 2026-08-28T04:03:32.782699+00:00)

## What it is
A Laravel package by Spatie that provides view models: classes that prepare and transform data for views, keeping controllers slim. It offers a simple ViewModel base class to encapsulate view-specific logic.

## Use cases
- move view preparation logic out of fat Laravel controllers
- pass structured data objects to Blade views
- organize complex view data like categories and URLs in one class
- replace or complement Laravel view composers
- keep create/edit form controllers clean

## When to choose
- you use Laravel and controllers are doing heavy data preparation for views
- you want an alternative to view composers with explicit per-action data
- you prefer object-oriented view data over passing loose arrays

## When to avoid
- you don't use Laravel or PHP
- your views are simple and controllers are already thin
- you rely on Blade components or Livewire for view logic

## Facets
- artifact type: library
- maturity: stable
- function: templating, middleware
- domain: web-development, backend, developer-tools
- platform: php
- tags: laravel, view-models, mvc, spatie, blade

## Member repositories
- spatie/laravel-view-models (main) score 72

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:32.782699+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:49:14.199176+00:00, confidence not recorded.
  - readme: https://github.com/spatie/laravel-view-models (fetched 2026-08-28T04:03:32.782699+00:00, sha 963936e3f223)
  - homepage: https://spatie.be/open-source (fetched 2026-08-29T12:51:28.003481+00:00, sha 6ed5abf69535)
  - site_page: https://spatie.be/docs (fetched 2026-08-29T12:51:28.007327+00:00, sha 08e024d86d95)
  - site_page: https://spatie.be/about-us (fetched 2026-08-29T12:51:28.009938+00:00, sha d3cb88e4b34c)
- Data as of 2026-08-30T08:39:29.467469+00:00.
