PHPackages                             jcsoriano/laravel-crud-templates - 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. jcsoriano/laravel-crud-templates

ActiveLibrary[Admin Panels](/categories/admin)

jcsoriano/laravel-crud-templates
================================

Laravel CRUD Templates - Generate complete CRUD operations with a single command

v1.5.0(5mo ago)41[5 PRs](https://github.com/jcsoriano/laravel-crud-templates/pulls)MITPHPPHP ^8.4CI passing

Since Oct 26Pushed 1mo agoCompare

[ Source](https://github.com/jcsoriano/laravel-crud-templates)[ Packagist](https://packagist.org/packages/jcsoriano/laravel-crud-templates)[ Docs](https://github.com/jcsoriano/laravel-crud-templates)[ GitHub Sponsors]()[ RSS](/packages/jcsoriano-laravel-crud-templates/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (13)Versions (14)Used By (0)

Laravel CRUD Templates
======================

[](#laravel-crud-templates)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4b24a4c374c0dbf0b4486db894000648b590bd014cea1c8e5877a3ff3becd794/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a63736f7269616e6f2f6c61726176656c2d637275642d74656d706c617465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jcsoriano/laravel-crud-templates)[![GitHub Tests Action Status](https://camo.githubusercontent.com/9a2babdcdd7dd184271efdc6f6887c5c0d519b2a2cc1c91fb58cdcf0d02bc083/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a63736f7269616e6f2f6c61726176656c2d637275642d74656d706c617465732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/jcsoriano/laravel-crud-templates/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/de9b0405d05df0d2acc7fbb43ad1ee17489b1829e098843fb97e6fb499c240b0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a63736f7269616e6f2f6c61726176656c2d637275642d74656d706c617465732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/jcsoriano/laravel-crud-templates/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)

CRUD Templates for Laravel allows you to generate controllers, models, policies, requests, resources, migrations, factories, and even tests - all the files you need to complete CRUD features with a single command.

You can completely modify the template or create your own templates to fit your project's conventions perfectly.

[![Demo](docs/public/demo.gif)](docs/public/demo.gif)

Requirements
------------

[](#requirements)

- PHP 8.4 or higher
- Laravel 11.0 or 12.0

Installation
------------

[](#installation)

You can install the package via Composer as a dev dependency:

```
composer require --dev jcsoriano/laravel-crud-templates
```

The package will automatically register itself via Laravel's package discovery.

### Publishing Stubs (Optional)

[](#publishing-stubs-optional)

You can publish the stubs to customize them:

```
php artisan vendor:publish --tag="crud-templates-stubs"
```

The Command
-----------

[](#the-command)

To generate a CRUD feature, you may use this command:

```
php artisan crud:generate
  {model : The name of the model}
  {--fields= : The fields to generate. Format: field1:type1,field2?:type2}
  {--table= : The database table to generate the fields from}
  {--template=api : The CRUD template to generate}
  {--skip= : List of files you want to skip}
  {--options= : Other options to pass to the generator. Format: key1:value1,key2:value2}
  {--force : Overwrite existing files}

```

Quick Start Example
-------------------

[](#quick-start-example)

Sample command to generate a fully functioning RESTful API:

```
php artisan crud:generate Content/Post --template=api --fields="title:string,content:text,published_at:datetime,category:belongsTo,comments:hasMany,status:enum:PublishStatus" --options="scope:user"

```

### Generated Files

[](#generated-files)

This command generates all the files needed to complete the CRUD feature, from routes, to validation, to authorization, to API responses, to migrations, to factories, to tests, and more.

- `app/Http/Controllers/Api/Content/PostController.php`
- `app/Models/Content/Post.php`
- `app/Policies/PostPolicy.php`
- `app/Http/Requests/Content/StorePostRequest.php`
- `app/Http/Requests/Content/UpdatePostRequest.php`
- `app/Http/Resources/Content/PostResource.php`
- `database/migrations/{timestamp}_create_posts_table.php`
- `database/migrations/{timestamp}_create_{pivot}_tables.php` (if belongsToMany or morphToMany relationships are present)
- `database/factories/Content/PostFactory.php`
- `tests/Feature/Api/Content/PostControllerTest.php`
- API routes automatically added to `routes/api.php` (will run `install:api` if the file doesn't exist yet)
- Laravel Pint run on all generated files

### Generated Routes

[](#generated-routes)

The command automatically registers the following routes in your `routes/api.php` file:

HTTP MethodURIActionDescriptionGET`/api/posts``index`List all posts (paginated)POST`/api/posts``store`Create a new postGET`/api/posts/{id}``show`Show a specific postPUT/PATCH`/api/posts/{id}``update`Update a postDELETE`/api/posts/{id}``destroy`Delete a post### Response Format

[](#response-format)

#### Single Resource:

[](#single-resource)

```
{
  "data": {
    "id": 1,
    "title": "My Post",
    "content": "...",
    "category": { "...": "..." },
    "comments": [ { "...": "..." } ],
    "status": "published",
    "published_at": "2024-01-01T00:00:00.000000Z",
    "created_at": "2024-01-01T00:00:00.000000Z",
    "updated_at": "2024-01-01T00:00:00.000000Z"
  }
}
```

#### Collection (with pagination):

[](#collection-with-pagination)

```
{
  "data": [
    { "The Post object as above" },
  ],
  "links": { "first": "...", "last": "...", "prev": null, "next": "..." },
  "meta": { "current_page": 1, "per_page": 15, "total": 50 }
}
```

### Validation Rules

[](#validation-rules)

The request classes automatically include appropriate validation:

**StorePostRequest:**

```
public function rules(): array
{
    return [
        'title' => ['required', 'string', 'max:255'],
        'content' => ['required', 'string'],
        'published_at' => ['required', 'date'],
        'category_id' => ['bail', 'required', 'exists:categories,id'],
        'status' => ['required', Rule::enum(PublishStatus::class)],
    ];
}
```

### Model Enhancements

[](#model-enhancements)

The generated `Post` model will include several automatic enhancements:

**Relationship Methods:**

```
public function category(): BelongsTo
{
    return $this->belongsTo(Category::class);
}

public function comments(): HasMany
{
    return $this->hasMany(Comment::class);
}
```

**Type Casting:**

```
protected $casts = [
    'published_at' => 'immutable_datetime',  // Automatic datetime casting
    'status' => PublishStatus::class,        // Enum casting
];
```

**Fillable Fields:**

```
protected $fillable = [
    'title',
    'content',
    'published_at',
    'category_id',
    'status',
];
```

### Migration with Foreign Keys

[](#migration-with-foreign-keys)

The migration includes proper foreign key constraints:

```
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->text('content');
    $table->dateTime('published_at');
    $table->foreignId('category_id')->constrained();
    $table->string('status');
    $table->timestamps();
});
```

### API Resource

[](#api-resource)

The generated `PostResource` automatically includes relationships:

```
public function toArray($request): array
{
    return [
        ...
        'category' => CategoryResource::make($this->whenLoaded('category')),
        'comments' => CommentResource::collection($this->whenLoaded('comments')),
    ];
}
```

Documentation
-------------

[](#documentation)

📚 **[View Full Documentation](https://laravelcrudtemplates.com)**

### Getting Started

[](#getting-started)

- [Installation](https://laravelcrudtemplates.com/guide/installation) - Requirements and installation guide
- [Quick Start](https://laravelcrudtemplates.com/guide/quick-start) - Generate your first CRUD in minutes

### Available Templates

[](#available-templates)

- [API Template](https://laravelcrudtemplates.com/templates/api) - RESTful API CRUD generation
- [Creating Your Own Template](https://laravelcrudtemplates.com/templates/custom) - Create templates for your own use cases

### Using Templates

[](#using-templates)

- [Field Types](https://laravelcrudtemplates.com/guide/field-types) - Complete list of supported field types
- [Relationships](https://laravelcrudtemplates.com/guide/relationships) - Working with model relationships
- [Generate from Schema](https://laravelcrudtemplates.com/guide/generate-from-schema) - Generate from existing database tables

### Customizing Templates

[](#customizing-templates)

- [Customizing Stubs](https://laravelcrudtemplates.com/templates/customizing-stubs) - Modify stub templates
- [Customizing Generators](https://laravelcrudtemplates.com/templates/customizing-generators) - Override file generators
- [Customizing Field Types](https://laravelcrudtemplates.com/templates/customizing-field-types) - Extend with custom field types
- [Customizing Printers](https://laravelcrudtemplates.com/templates/customizing-printers) - Customize code output

Support
-------

[](#support)

If you find this package useful and would like to support its development, consider supporting me through one of these platforms:

[![Buy Me a Coffee](https://camo.githubusercontent.com/463cff2f18a3412e282d52300c863fabf6660a835e16e250d41a4efd7d01c5c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275792532304d6525323061253230436f666665652d4646444430303f7374796c653d666f722d7468652d6261646765266c6f676f3d6275792d6d652d612d636f66666565266c6f676f436f6c6f723d626c61636b)](https://buymeacoffee.com/jc.soriano)[![Patreon](https://camo.githubusercontent.com/f39892b79b4beea40518ca4d5f06f767daa67ab37e0a261952c1bb311b54212b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50617472656f6e2d4639363835343f7374796c653d666f722d7468652d6261646765266c6f676f3d70617472656f6e266c6f676f436f6c6f723d7768697465)](https://www.patreon.com/cw/jcsoriano)[![Ko-fi](https://camo.githubusercontent.com/7d4f139ba52150c815e24b96f122eb6b87b1f5408021685208e0a04a49022cae/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4b6f2d2d66692d4631363036313f7374796c653d666f722d7468652d6261646765266c6f676f3d6b6f2d6669266c6f676f436f6c6f723d7768697465)](https://ko-fi.com/jcsoriano)

Your support helps me continue building and maintaining this package. Thank you! 🙏

Coming Soon
-----------

[](#coming-soon)

1. **Filament CRUD Generator** - a Filament GUI for generating CRUD features
2. **Livewire CRUD Generator** - a CRUD template built for the Livewire starter kit
3. **Vue CRUD Generator** - a CRUD template built for the Vue starter kit
4. **React CRUD Generator** - a CRUD template built for the React starter kit

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [JC Soriano](https://github.com/jcsoriano)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance82

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 83.1% 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 ~4 days

Total

7

Last Release

171d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/39004d6bc662bfcbd67174e0248cbbec09dae14cc9a38e60bcb0cd4771a373b1?d=identicon)[jcsoriano](/maintainers/jcsoriano)

---

Top Contributors

[![jcsoriano](https://avatars.githubusercontent.com/u/5937317?v=4)](https://github.com/jcsoriano "jcsoriano (69 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravelgeneratortemplatescrudJC Sorianolaravel-crud-templates

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jcsoriano-laravel-crud-templates/health.svg)

```
[![Health](https://phpackages.com/badges/jcsoriano-laravel-crud-templates/health.svg)](https://phpackages.com/packages/jcsoriano-laravel-crud-templates)
```

###  Alternatives

[guava/filament-knowledge-base

A filament plugin that adds a knowledge base and help to your filament panel(s).

206120.5k1](/packages/guava-filament-knowledge-base)[a2insights/filament-saas

Filament Saas for A2Insights

161.1k](/packages/a2insights-filament-saas)

PHPackages © 2026

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