joaoroyosilva/eloquent-nested-attributes
Larablocks Analysis
joaoroyosilva/eloquent-nested-attributes works with Laravel 7, 8 and 9 (latest release 1.0.3, Jan 24, 2023), all past end of life (the last on Feb 6, 2024): no more fixes, even for security.
Laravel 5 in earlier releases.
Recommendation checks
Use with careUse with care: meets 0 of 4 checks.
- Supports only Laravel 7, 8 and 9, past end of life since Feb 6, 2024
- No release in the last 12 months (last: Jan 24, 2023)
- 1 downloads a month (needs 10,000)
- 0 GitHub stars (needs 100)
State
Quiet- Last stable release: Jan 24, 2023.
- No releases in the last 12 months.
- First released: Aug 29, 2017.
- Monthly downloads: 1, down 80% from six months ago.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.
| Install | |
|---|---|
composer require joaoroyosilva/eloquent-nested-attributes |
|
| Latest Version: | 1.0.3 |
| PHP: | >=7.2 |
| Laravel: | 7 · 8 · 9 |
| Older releases: | 5 |
| License: | MIT |
| Last Updated: | Sep 11, 2026 |
| Links: | GitHub · Packagist |
eloquent-nested-attributes
**Forked from mits87/eloquent-nested-attributes
Nested attributes allow you to save attributes on associated records through the parent. By default nested attribute updating is turned off and you can enable it using the $nested attribute. When you enable nested attributes an attribute writer is defined on the model.
Structure
If any of the following are applicable to your project, then the directory structure should follow industry best practises by being named the following.
src/
tests/
vendor/
Install
Via Composer
$ composer require mits87/eloquent-nested-attributes
Usage
namespace App;
use Eloquent\NestedAttributes\Model;
class Post extends Model
{
protected $fillable = ['title'];
protected $nested = ['option', 'comments'];
public function option() {
//it can be also morphOne
return $this->hasOne('App\Option');
}
public function comments() {
//it can be also morphMany
return $this->hasMany('App\Comment');
}
}
or
namespace App;
use Illuminate\Database\Eloquent\Model;
use Eloquent\NestedAttributes\Traits\HasNestedAttributesTrait;
class Post extends Model
{
use HasNestedAttributesTrait;
...
}
usage:
\App\Post::create([
'title' => 'Some text',
'option' => [
'info' => 'some info'
],
'comments' => [
[
'text' => 'Comment 1'
], [
'text' => 'Comment 2'
],
]
]);
\App\Post::findOrFail(1)->update([
'title' => 'Better text',
'option' => [
'info' => 'better info'
],
'comments' => [
[
'id' => 2,
'text' => 'Comment 2'
],
]
]);
to delete nested row you should pass _destroy attribute:
\App\Post::findOrFail(1)->update([
'title' => 'Better text',
'option' => [
'info' => 'better info'
],
'comments' => [
[
'id' => 2,
'_destroy' => true
],
]
]);
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email mits87@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Related Packages
Maps Laravel and lumen Eloquent models to Elasticsearch types.
Make easy query builder / eloquent queries based on requests for API Response
Eloquent Double Entry Accounting with focus on IFRS Compliant Reporting
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.0.3 | >=7.2 | ^7.0| | MIT | |
| 0.0.6 | >=7.0 | ~5.1 | MIT | |
| 0.0.4 | >=7.0 | ~5.1 | MIT | |
| 0.0.3 | >=7.0 | ~5.1 | MIT | |
| 0.0.2 | ~5.6| | ~5.1 | MIT | |
| 0.0.1 | ~5.6| | ~5.1 | MIT |