---
title: 'Inspect Eloquent models and collections in Tinker'
description: 'Inspect a small Eloquent collection, select explicit columns, limit the rows, and map the result to an array that leaves private or heavy fields out.'
canonical_url: 'https://larabench.com/laravel-tinker-workflows/inspect-eloquent-models-and-collections'
md_url: 'https://larabench.com/laravel-tinker-workflows/inspect-eloquent-models-and-collections.md'
last_updated: '2026-07-28'
---
# Inspect Eloquent models and collections in Tinker

> Inspect a small Eloquent collection, select explicit columns, limit the rows, and map the result to an array that leaves private or heavy fields out.

## Direct Answer

Query a small number of models, select only the needed columns, and map each model to an explicit array before printing or returning it.

## When To Use This

Use this to confirm casts, scopes, statuses, selected attributes, or the shape of a small Eloquent collection. Avoid `Model::all()` on a large or sensitive table.

## Terminal Approach

```bash
php artisan tinker
```

## LaraBench Approach

Open Run Code in Tinker mode, run the explicit-field snippet, inspect the structured output and SQL panel, then save it only if the selected fields are safe to reuse.

## Inspection Snippet

```php
use App\Models\User;

return User::query()
    ->select(['id', 'name', 'status'])
    ->latest('id')
    ->limit(10)
    ->get()
    ->map(fn (User $user): array => $user->only([
        'id',
        'name',
        'status',
    ]));
```

## Expected Result

The result contains at most ten rows with only `id`, `name`, and `status`. The SQL panel shows one bounded select query unless a scope, accessor, or relationship adds work.

## Troubleshooting

- If rows are absent, inspect global scopes and soft-delete behavior.
- If extra queries appear, check accessors and relationships used while mapping.
- If output is too large, reduce the columns and limit.

## Safety Notes

A select is read-only, but its output can still expose private data. Avoid credentials, tokens, personal details, payment fields, and unbounded relationships.

## Related Sources

- [Laravel Eloquent retrieval documentation](https://laravel.com/docs/13.x/eloquent#retrieving-models)
- [Laravel Eloquent collections documentation](https://laravel.com/docs/13.x/eloquent-collections)
- [LaraBench clean output docs](https://larabench.com/docs/basic-usage/clean-output)

## Related Workflows

- [Find N+1 queries in a Laravel snippet](https://larabench.com/laravel-tinker-workflows/find-laravel-n-plus-one-queries)
- [Benchmark Eloquent and query builder code](https://larabench.com/laravel-tinker-workflows/benchmark-eloquent-queries)

## Canonical Page

- [HTML page](https://larabench.com/laravel-tinker-workflows/inspect-eloquent-models-and-collections)
- [Markdown mirror](https://larabench.com/laravel-tinker-workflows/inspect-eloquent-models-and-collections.md)

## Glossary

- [Laravel workflow glossary](https://larabench.com/docs/reference/glossary)

## Sitemap

See the full [sitemap](https://larabench.com/sitemap.md) for all public pages.
