PHPackages                             onkbear/backpack-nested-crud - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. onkbear/backpack-nested-crud

ActiveLibrary[Admin Panels](/categories/admin)

onkbear/backpack-nested-crud
============================

2.0.2(5y ago)218.4k10[2 issues](https://github.com/onkbear/backpack-nested-crud/issues)MITBlade

Since Nov 14Pushed 5y ago3 watchersCompare

[ Source](https://github.com/onkbear/backpack-nested-crud)[ Packagist](https://packagist.org/packages/onkbear/backpack-nested-crud)[ Docs](https://github.com/onkbear/backpack-nested-crud)[ RSS](/packages/onkbear-backpack-nested-crud/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (12)Used By (0)

Backpack Nested Crud
====================

[](#backpack-nested-crud)

[![Latest Stable Version](https://camo.githubusercontent.com/d90f1a29056c8eef8cf6a38a1f63c5a5555b20cbc34a023d7d85a1e6276ee6e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6e6b626561722f6261636b7061636b2d6e65737465642d637275642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/onkbear/backpack-nested-crud)[![Software License](https://camo.githubusercontent.com/87c4a0ebe59b623c7778ef616675a72bd908ed870fb9c7f60976e5e5bac7a74f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f6e6b626561722f6261636b7061636b2d6e65737465642d637275643f7374796c653d666c61742d737175617265)](LICENSE)

This package gives nested CRUD operations on your edit page.

Inspired by [Nested resources in Backpack CRUD](https://backpackforlaravel.com/articles/tutorials/nested-resources-in-backpack-crud)

E.g.

Gives the avility of CRUD operations of `comment` model as a field on `user` edit page.

For [Laravel-Backpack/CRUD](https://github.com/Laravel-Backpack/CRUD) v4.0, please use `^1.1`.

[![Demo](https://user-images.githubusercontent.com/6011203/71384896-04b19080-25dc-11ea-9c97-6ee38d31619c.gif)](https://user-images.githubusercontent.com/6011203/71384896-04b19080-25dc-11ea-9c97-6ee38d31619c.gif)

Install
-------

[](#install)

```
composer require onkbear/backpack-nested-crud
```

Usage
-----

[](#usage)

There are four (instead of create, read, update, delete) nested CRUD operations.

```
    use \Onkbear\NestedCrud\app\Http\Controllers\Operations\NestedListOperation;
    use \Onkbear\NestedCrud\app\Http\Controllers\Operations\NestedCreateOperation;
    use \Onkbear\NestedCrud\app\Http\Controllers\Operations\NestedUpdateOperation;
    use \Onkbear\NestedCrud\app\Http\Controllers\Operations\NestedDeleteOperation;
```

Example
-------

[](#example)

Please create `User` model and `Comment` model with relationship.

Please create `UserCrudController`.

```
class UserCrudController extends CrudController
{
    use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;

    public function setup()
    {
        CRUD::setModel('App\Models\User');
        CRUD::setRoute(config('backpack.base.route_prefix').'/user');
        CRUD::setEntityNameStrings('user', 'users');
    }

    protected function setupListOperation()
    {
        CRUD::addColumns(['name']);
    }

    protected function setupCreateOperation()
    {
        CRUD::addField([
            'name'  => 'name',
            'label' => 'Name',
            'type'  => 'text',
            'tab'   => 'Texts',
        ]);
    }

    protected function setupUpdateOperation()
    {
        $this->setupCreateOperation();

        CRUD::addField([
            'name'      => 'comments',
            'label'     => 'Comment',
            'type'      => 'nested_crud',
            'target'    => 'comment',
            'model'     => 'App\Models\Comment',
            'tab'       => 'Comments',  // optional
        ]);
    }
}
```

### Create the CRUD controller

[](#create-the-crud-controller)

```
use App\Http\Requests\CommentRequest as StoreRequest;
use App\Http\Requests\CommentRequest as UpdateRequest;

class UserCommentCrudController extends CrudController
{
    use \Onkbear\NestedCrud\app\Http\Controllers\Operations\NestedListOperation;
    use \Onkbear\NestedCrud\app\Http\Controllers\Operations\NestedCreateOperation;
    use \Onkbear\NestedCrud\app\Http\Controllers\Operations\NestedUpdateOperation;
    use \Onkbear\NestedCrud\app\Http\Controllers\Operations\NestedDeleteOperation;

    public function setup()
    {
        // set the Eloquent object
        CRUD::setModel(\App\Models\Comment::class);

        // get the user_id parameter
        $userId = \Route::current()->parameter('user_id');

        // set a different route for the admin panel buttons
        CRUD::setRoute(config('backpack.base.route_prefix').'/user/'.$userId.'/comment');

        // show only specific user's comments
        CRUD::addClause('where', 'user_id', $userId);

        // ...
    }

    protected function setupNestedListOperation()
    {
        // ...
    }

    protected function setupNestedCreateOperation()
    {
        CRUD::setValidation(StoreRequest::class);

        // get the user_id parameter
        $userId = \Route::current()->parameter('user_id');

        // add a foreign key field as a hidden field (may need only for create operation)
        CRUD::addField([
            'name' => 'user_id',
            'type' => 'hidden',
            'value' => $userId
        ]);

        // ...
    }

    protected function setupNestedUpdateOperation()
    {
        CRUD::setValidation(UpdateRequest::class);

        // ...
    }
```

### Add the route

[](#add-the-route)

Setup the route in `route/custom.php`

```
    Route::crud('user/', 'UserCrudController');
    Route::group(['prefix' => 'user/{user_id}'], function() {
        Route::crud('comment', 'UserCommentCrudController');
    });
```

You have following routes.

- `admin/user/`
- `admin/user/{user_id}/comment/`

That's it.

You can also use backpack operations into `UserCommentCrudController` or extend `CommentCrudController` if it is exist.

Customize views for list view
-----------------------------

[](#customize-views-for-list-view)

There are two templates for list view.

- `nested_crud::nested_list` : table view (default)
- `nested_crud::nested_grid_list` : grid view

[![Grid View](https://user-images.githubusercontent.com/6011203/71385071-15163b00-25dd-11ea-9b99-880d8f52af67.png)](https://user-images.githubusercontent.com/6011203/71385071-15163b00-25dd-11ea-9b99-880d8f52af67.png)

If you would like to use grid view, simply use the set method below.

```
// UserCommentCrudController.php

    protected function setupNestedListOperation()
    {
        $this->crud->setListView('nested_crud::nested_grid_list');
    }
```

If you created view files with exact same name in `resources/views/vendor/backpack/nested_crud` folder, it will override.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~34 days

Total

10

Last Release

2102d ago

Major Versions

1.1.0 → 4.1.x-dev2020-05-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/049e35f370ce80c67e536651cb670c8995641cf31591dccc1eb9c1b3455e1071?d=identicon)[onkbear](/maintainers/onkbear)

---

Top Contributors

[![onkbear](https://avatars.githubusercontent.com/u/6011203?v=4)](https://github.com/onkbear "onkbear (23 commits)")[![DiyanDev](https://avatars.githubusercontent.com/u/24225940?v=4)](https://github.com/DiyanDev "DiyanDev (1 commits)")

---

Tags

crudbackpacklaravel backpack

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/onkbear-backpack-nested-crud/health.svg)

```
[![Health](https://phpackages.com/badges/onkbear-backpack-nested-crud/health.svg)](https://phpackages.com/packages/onkbear-backpack-nested-crud)
```

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.6M217](/packages/backpack-crud)[backpack/pagemanager

Create admin panels for presentation websites on Laravel, using page templates and Backpack\\CRUD.

373537.1k6](/packages/backpack-pagemanager)[backpack/newscrud

An admin panel for news with categories and tags, using Backpack\\CRUD on Laravel 5.

236162.7k1](/packages/backpack-newscrud)[backpack/backupmanager

Admin interface for managing backups in Backpack, on Laravel 5.2+

336387.0k2](/packages/backpack-backupmanager)[backpack/langfilemanager

An interface to edit language files, for Laravel Backpack.

91232.9k1](/packages/backpack-langfilemanager)[novius/laravel-backpack-crud-extended

This package extends Laravel Backpack\\CRUD

589.1k2](/packages/novius-laravel-backpack-crud-extended)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
