---
title: "lint/laravel/prefer-casts-method"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="lint/laravel/prefer-casts-method" />

In the [`coding-style`](/docs/rules/sets/coding-style) set. Safe fix. Runs when laravel is installed.

## What it does

Detects the `$casts` property on an Eloquent model. Laravel 11 introduced the `casts()`

## Configuration

```toml title="pun.toml"
[lint.rules]
"laravel/prefer-casts-method" = "error"
```

To skip it in some files or lines, add an [override](/docs/configuration/pun-toml#lint) or an [ignore comment](/docs/configuration/ignore-comments).

## Replaces

- [`prefer-casts-method`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#prefer-casts-method) (mago-linter)

[More lint/laravel rules](/docs/rules/lint/laravel) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
