Laravel Packages

Eloquent Inspector for Laravel

Published
Eloquent Inspector for Laravel image

Laravel Eloquent Inspector is a package by Andrea Marco Sartori to inspect models and collect properties, relationships, and more.

This package provides helpful information about the use statements of a model, model properties, and model relationships:

 
// All `use` statements for a model
$useStatements = Inspector::inspect(User::class)->getUseStatements();
/*
[
'Model' => 'Illuminate\Database\Eloquent\Model',
'Baz' => 'Foo\Bar',
]
*/
 
 
// Model properties
$properties = Inspector::inspect(User::class)->getProperties();
 
$properties['id']->name; // id
$properties['id']->type; // int
$properties['id']->dbType; // integer
$properties['id']->nullable; // false
$properties['id']->default; // null
 
 
$relationships = Inspector::inspect(User::class)->getRelationships();
 
$relationships['posts']->name; // posts
$relationships['posts']->type; // hasMany
// Illuminate\Database\Eloquent\Relations\HasMany
$relationships['posts']->class;
$relationships['posts']->model; // App\Models\Post
$relationships['posts']->relatesToMany; // true

Model relationships and properties return an array, with the key being the property/relationship name and the value being an object with detailed information about that property/relationship.

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

serpapi logo
SerpApi

The Web Search API for Your LLM and AI Applications

Visit SerpApi

The latest

View all →
Image Dominant Color and HEIC Support in Laravel 13.24 image

Image Dominant Color and HEIC Support in Laravel 13.24

Read article
Official Laravel Zed Extension: LSP for PHP & Blade image

Official Laravel Zed Extension: LSP for PHP & Blade

Read article
Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD image

Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD

Read article
PhpStorm 2026.2 Released image

PhpStorm 2026.2 Released

Read article
Laravel Doctor: Diagnose Your App With One Artisan Command image

Laravel Doctor: Diagnose Your App With One Artisan Command

Read article
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article