Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Eloquent Model

Eloquent Model Laravel Package

supportpal/eloquent-model

Eloquent-style base Model for PHP/Laravel to build custom, non-database models. Supports accessors/mutators, attribute casting, guarded/fillable and hidden fields, appended attributes, and easy array/JSON conversion.

View on GitHub
Deep Wiki
Context7

This model provides an eloquent-like base class that can be used to build custom models in Laravel and other frameworks

Frequently asked questions about Eloquent Model
Can I use this package to replace Eloquent for database models in Laravel?
No, this package is not a full ORM replacement. It lacks query building, relationships, and migrations—use it only for non-database models like DTOs, API payloads, or caching layers. For database models, stick with Eloquent.
How do I install `jenssegers/model` in a Laravel project?
Run `composer require jenssegers/model` in your project root. No additional Laravel-specific configuration is required, though avoid naming conflicts with existing Eloquent models.
Does this package support attribute casting like Eloquent?
Yes, it supports casting (e.g., `protected $casts = ['age' => 'integer']`) just like Eloquent. Casts work identically for serialization to arrays or JSON.
Will this work with Laravel 10+? Are there version compatibility issues?
The package is framework-agnostic and should work with Laravel 10+. However, test thoroughly for edge cases, as it lacks Laravel’s service container integration. No Eloquent-specific features (like query builder) are supported.
How do I handle data persistence (saving/loading) with this model?
This package doesn’t include persistence logic. Override the `save()` method manually (e.g., for API calls, file storage, or Redis) and implement `load()` if needed. Example: `return API::post('/items', $this->attributes);`.
Can I use hidden/guarded/appended attributes like Eloquent?
Yes, it fully supports `$hidden`, `$guarded`, and `$appends` just like Eloquent. These work during `toArray()` or `toJson()` serialization, hiding sensitive fields or appending computed attributes.
Is this package actively maintained? When was the last update?
Check the GitHub repo for recent activity, but the package appears lightweight and stable. As of 2026 (placeholder), verify the `composer.json` for the latest release date. No Laravel-specific dependencies mean lower maintenance risk.
How do I test accessors/mutators in PHPUnit?
Test accessors/mutators by instantiating the model, setting attributes, and asserting the transformed values. Example: `$user = new User(['birthday' => '1990-01-01']); $this->assertInstanceOf(DateTime::class, $user->birthday);`. Use unit tests for logic and integration tests for serialization.
What’s the performance impact compared to native PHP arrays/objects?
This package adds minimal overhead for serialization (e.g., casting, hidden fields). Benchmark against native arrays/objects for critical paths, but expect ~10–20% slower serialization due to reflection and accessor calls.
Are there alternatives for lightweight Laravel models without ORM?
For Laravel, consider `spatie/array-to-object` for simple DTOs or `laravel/serializable-closure` for custom serialization. For Eloquent-like features without persistence, this package is a solid choice, but evaluate `illuminate/support` traits if you need Laravel-specific helpers.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor