PHPackages                             aminul/crud-generate - 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. aminul/crud-generate

ActiveLibrary

aminul/crud-generate
====================

Laravel package to generate complete CRUD structure with repository pattern, service classes, and beautiful views. Follows Laravel best pattern

028PHP

Since Nov 30Pushed 5mo agoCompare

[ Source](https://github.com/aminulbinnoor/laravel-crud-generate)[ Packagist](https://packagist.org/packages/aminul/crud-generate)[ RSS](/packages/aminul-crud-generate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel CRUD Generator
======================

[](#laravel-crud-generator)

A powerful Laravel package that automatically generates complete CRUD (Create, Read, Update, Delete) structure with repository pattern, service classes, professional Bootstrap views, and RESTful APIs. Save hours of development time with a single command!

🚀 Features
----------

[](#-features)

- **✅ Complete CRUD Structure** - Models, Controllers, Views, Routes, APIs, and more
- **✅ Repository &amp; Service Pattern** - Clean architecture with automatic interface binding
- **✅ Relationship Support** - All Eloquent relationship types (hasMany, belongsTo, belongsToMany, etc.)
- **✅ Professional AdminLTE UI** - Beautiful, responsive admin interface
- **✅ RESTful API Ready** - Complete API endpoints with relationship support
- **✅ Audit Trail** - Automatic `created_by`, `updated_by`, `deleted_by` tracking
- **✅ Form Validation** - Automatic request validation with relationship rules
- **✅ Layout System** - Professional admin layout automatically created
- **✅ Customizable Fields** - Support for various field types and validation
- **✅ Sample Data** - Optional sample data generation

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require aminul/crud-generate
```

That's it! No configuration needed.

⚡ Quick Start
-------------

[](#-quick-start)

Generate a complete CRUD for any model with a single command:

```
php artisan make:crud Product --fields="name:string,description:text,price:decimal,is_active:boolean"
```

🎯 Relationship Examples
-----------------------

[](#-relationship-examples)

### 1. One-to-Many Relationship (Blog System)

[](#1-one-to-many-relationship-blog-system)

**Post with Comments and Category:**

```
# Create Category first
php artisan make:crud Category --fields="name:string,description:text,is_active:boolean"

# Create Post with Category relationship
php artisan make:crud Post --fields="title:string,content:text,is_published:boolean" --relations="belongsTo:Category,hasMany:Comment"

# Create Comment with Post and User relationships
php artisan make:crud Comment --fields="content:text,is_approved:boolean" --relations="belongsTo:Post,belongsTo:User"
```

### 2. Many-to-Many Relationship (E-commerce)

[](#2-many-to-many-relationship-e-commerce)

**Product with Categories and Tags:**

```
# Create Product with multiple categories and tags
php artisan make:crud Product --fields="name:string,sku:string:unique,description:text,price:decimal,quantity:integer" --relations="belongsToMany:Category,belongsToMany:Tag"

# Create Category
php artisan make:crud Category --fields="name:string,description:text"

# Create Tag
php artisan make:crud Tag --fields="name:string,color:string"
```

### 3. Polymorphic Relationships (Comment System)

[](#3-polymorphic-relationships-comment-system)

**Comments that can belong to Posts or Videos:**

```
# Create polymorphic Comment
php artisan make:crud Comment --fields="content:text,is_approved:boolean" --relations="morphTo:commentable,belongsTo:User"

# Create Post with comments
php artisan make:crud Post --fields="title:string,content:text" --relations="morphMany:Comment"

# Create Video with comments
php artisan make:crud Video --fields="title:string,url:string,duration:integer" --relations="morphMany:Comment"
```

🛠 Supported Relationship Types
------------------------------

[](#-supported-relationship-types)

RelationshipCommand SyntaxDescription**One-to-One**`hasOne:Profile`One model has one related model**One-to-Many**`hasMany:Comment`One model has many related models**Many-to-One**`belongsTo:User`Many models belong to one parent**Many-to-Many**`belongsToMany:Tag`Models have many-to-many relationship**Polymorphic One**`morphOne:Image`One polymorphic relationship**Polymorphic Many**`morphMany:Comment`Many polymorphic relationships**Polymorphic To**`morphTo:commentable`Inverse polymorphic relationship📁 Generated Structure
---------------------

[](#-generated-structure)

When you run the command, it creates:

```
app/
├── Models/
│   ├── BaseModel.php          # Base model with audit trail
│   ├── Post.php               # Your model with relationships
│   └── Comment.php
├── Repositories/
│   ├── Contracts/
│   │   ├── PostRepositoryInterface.php
│   │   └── CommentRepositoryInterface.php
│   ├── PostRepository.php     # With relationship methods
│   └── CommentRepository.php
├── Services/
│   ├── PostService.php        # With relationship business logic
│   └── CommentService.php
├── Http/
│   ├── Controllers/
│   │   ├── PostController.php # With relation data loading
│   │   ├── CommentController.php
│   │   └── API/
│   │       ├── PostController.php     # API with relations
│   │       └── CommentController.php
│   └── Requests/
│       ├── StorePostRequest.php       # With relation validation
│       ├── UpdatePostRequest.php
│       ├── StoreCommentRequest.php
│       └── UpdateCommentRequest.php
resources/
└── views/
    ├── layouts/
    │   └── app.blade.php      # Professional AdminLTE layout
    ├── post/
    │   ├── index.blade.php    # With relation data display
    │   ├── create.blade.php   # With relation dropdowns
    │   ├── edit.blade.php
    │   └── show.blade.php     # With relation details
    └── comment/
        ├── index.blade.php
        ├── create.blade.php
        ├── edit.blade.php
        └── show.blade.php
database/
└── migrations/
    ├── create_posts_table.php         # With foreign keys
    └── create_comments_table.php      # With relation columns
routes/
├── web.php                    # Web routes with relations
└── api.php                    # API routes with relation endpoints

```

🌐 Automatic Web Features
------------------------

[](#-automatic-web-features)

### Form Dropdowns

[](#form-dropdowns)

Relationships automatically generate dropdown selects in forms:

```

    Category *

        Select Category
        @foreach($categories as $category)
            id ? 'selected' : '' }}>
                {{ $category->name }}

        @endforeach

```

### Data Display

[](#data-display)

Relationships are displayed in lists and show pages:

```
// In index view - shows related data
{{ $post->category->name }}
{{ $post->user->name }}

// In show view - shows full relationship details
Category: {{ $post->category->name }}
Author: {{ $post->user->name }}
Comments: {{ $post->comments_count }}
```

🔌 API Endpoints with Relations
------------------------------

[](#-api-endpoints-with-relations)

### Eager Loading

[](#eager-loading)

Load relationships via query parameters:

```
GET /api/posts?with=category,user,comments
GET /api/posts/1?with=category,comments.user
```

### Related Data Endpoints

[](#related-data-endpoints)

Get data for form dropdowns:

```
GET /api/posts/related-data
```

### Nested Resources

[](#nested-resources)

Access related models directly:

```
GET /api/posts/1/comments
GET /api/categories/1/posts
```

🎨 Professional UI Features
--------------------------

[](#-professional-ui-features)

- **AdminLTE 3** - Professional admin interface
- **DataTables** - Advanced tables with search and sort
- **Select2** - Enhanced dropdowns for relationships
- **Font Awesome** - Beautiful icons throughout
- **SweetAlert2** - Elegant confirmation dialogs
- **Responsive Design** - Works on all devices
- **Relationship Display** - Shows related data beautifully
- **Audit Trail** - Track creation and updates

🚨 After Generation
------------------

[](#-after-generation)

1. **Run migrations:**

    ```
    php artisan migrate
    ```
2. **Access your CRUD:**

    - Web: Visit `/posts` and `/comments`
    - API: Use `/api/posts` and `/api/comments` endpoints
3. **Test relationships:**

    - Create posts with categories
    - Add comments to posts
    - View related data in lists and details

📝 Field Types Supported
-----------------------

[](#-field-types-supported)

TypeExampleDescription`string``name:string`Short text (VARCHAR)`text``description:text`Long text (TEXT)`integer``quantity:integer`Whole numbers`decimal``price:decimal`Decimal numbers`boolean``is_active:boolean`True/False`date``birth_date:date`Date only`datetime``published_at:datetime`Date and time`email``email:string:unique`Email with validation`:unique``sku:string:unique`Unique constraint🎯 Perfect For
-------------

[](#-perfect-for)

- **Admin Panels** - Quick backend with relationships
- **Prototyping** - Rapid application development
- **MVP Development** - Get to market faster
- **Learning** - Study Laravel best practices with relationships
- **Team Projects** - Consistent code structure
- **Complex Systems** - Multi-model applications with relations

⚡ Pro Tips
----------

[](#-pro-tips)

1. **Generate related models first** - Create parent models before children
2. **Use `--sample` flag** - For testing with sample data
3. **Chain relationships** - Build complex systems step by step
4. **API first** - Use `?with=relation` parameter for eager loading
5. **Customize generated code** - All code follows Laravel best practices

---

**⭐ Star the repository if you find this package helpful!**

**💡 Pro Tip:** Start with simple relationships and gradually build complex systems. The package handles all the boilerplate code for you!

---

*Built with ❤️ for the Laravel community*

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance49

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c54011c6b914d94a25d098c17d9e238cfcdded4f62230fff8492b82100d799da?d=identicon)[aminulbinnoor](/maintainers/aminulbinnoor)

---

Top Contributors

[![aminulbinnoor](https://avatars.githubusercontent.com/u/17913718?v=4)](https://github.com/aminulbinnoor "aminulbinnoor (48 commits)")

### Embed Badge

![Health badge](/badges/aminul-crud-generate/health.svg)

```
[![Health](https://phpackages.com/badges/aminul-crud-generate/health.svg)](https://phpackages.com/packages/aminul-crud-generate)
```

PHPackages © 2026

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