PHPackages                             achillesp/laravel-crud-forms - 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. [Database &amp; ORM](/categories/database)
4. /
5. achillesp/laravel-crud-forms

ActiveLibrary[Database &amp; ORM](/categories/database)

achillesp/laravel-crud-forms
============================

Create CRUD Forms for Laravel Models.

6.0(2y ago)375.6k↓92.9%9MITBladePHP ^8.1CI passing

Since Nov 19Pushed 5d ago4 watchersCompare

[ Source](https://github.com/achillesp/laravel-crud-forms)[ Packagist](https://packagist.org/packages/achillesp/laravel-crud-forms)[ RSS](/packages/achillesp-laravel-crud-forms/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (6)Versions (17)Used By (0)

Laravel CRUD Forms
==================

[](#laravel-crud-forms)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ab3f5cc0f35d823f9e227db40f90ce7e377827fc6d3a066e51a827a550107ecb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616368696c6c6573702f6c61726176656c2d637275642d666f726d732e737667)](https://packagist.org/packages/achillesp/laravel-crud-forms)[![run-tests](https://github.com/achillesp/laravel-crud-forms/actions/workflows/run-tests.yml/badge.svg)](https://github.com/achillesp/laravel-crud-forms/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/ca8fe601d0fc632dcb74feb26243596e2c2e75cc55a14e97c64d4ff7e996f054/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616368696c6c6573702f6c61726176656c2d637275642d666f726d732e737667)](https://packagist.org/packages/achillesp/laravel-crud-forms)[![License](https://camo.githubusercontent.com/0e599a0a3d2f9dc5258dab253ea7406d8ef69d4556c9888ccfb9377a1598d6ce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616368696c6c6573702f6c61726176656c2d637275642d666f726d732e737667)](LICENSE.md)

Scaffold a complete CRUD (Create, Read, Update, Delete) interface for an Eloquent model — an index listing plus create/show/edit forms with validation and soft-delete support — by adding **one trait** to a resource controller. No generators and no reactive front-end: just a trait and a set of publishable, server-rendered Blade views (Bootstrap or Tailwind) that stay out of the way of the rest of your app. This aims to be used as a quick tool which does not interfere with the other parts of the application that it's used in.

```
use App\Models\Post;
use Achillesp\CrudForms\CrudForms;

class PostController extends Controller
{
    use CrudForms;

    public function __construct(Post $post)
    {
        $this->model = $post;

        $this->formFields = [
            ['name' => 'title',       'label' => 'Title',    'type' => 'text'],
            ['name' => 'body',        'label' => 'Body',     'type' => 'textarea'],
            ['name' => 'category_id', 'label' => 'Category', 'type' => 'select', 'relationship' => 'category'],
        ];
    }
}
```

```
// routes/web.php
Route::resource('posts', PostController::class);
```

That gives you a working CRUD UI for the `Post` model. See [Usage](#usage) for every available option, and [Views and themes](#views-and-themes) for styling.

Compatibility
-------------

[](#compatibility)

The latest release supports **Laravel 11, 12 and 13** on **PHP 8.2+** (PHP 8.3+ for Laravel 13). Composer installs the right version for your app automatically:

```
composer require achillesp/laravel-crud-forms

```

Older Laravel versions are covered by earlier major releases:

LaravelPackage version11, 12, 13`^9.0` (latest)10`^6.0`9`^5.0`8`^4.0`7`^3.0`6`^2.0`Installation
------------

[](#installation)

### Composer

[](#composer)

From the command line, run:

```
composer require achillesp/laravel-crud-forms

```

### Configuration

[](#configuration)

This package uses a config file which you can override by publishing it to your app's config dir.

```
php artisan vendor:publish --provider="Achillesp\CrudForms\CrudFormsServiceProvider" --tag=config

```

Usage
-----

[](#usage)

To use the package, you need to use the trait `Achillesp\CrudForms\CrudForms` in your model's controller and define your routes. The trait provides all the required methods for a Resource Controller, as well as a restore method in case of soft-deleted models.

### Routes

[](#routes)

If for example you have a `Post` model, you would define the route:

```
use App\Http\Controllers\PostController;

Route::resource('posts', PostController::class);
```

### Controller

[](#controller)

Then in your `PostController`, you will need to use the trait and also define a constructor where you give the needed details of the model.

```
use App\Models\Post;
use Achillesp\CrudForms\CrudForms;

class PostController extends Controller
{
    use CrudForms;

    public function __construct(Post $post)
    {
        $this->model = $post;
    }
}
```

In the controller's constructor you can define the properties which are handled by the controller. The available properties that can be defined are as follows.

### The model

[](#the-model)

This is the model, which should be passed in the constructor through Dependency Injection.

### The formFields array

[](#the-formfields-array)

This is an array of all the fields you need in the forms. Each field is declared as an array that has:

1. `name`: This is the model's attribute name, as it is in the database.
2. `label`: This is the field's label in the forms.
3. `type`: The type of the form input field that will be used. Accepted types are:
    - text
    - textarea
    - email
    - url
    - password
    - date
    - select
    - select\_multiple
    - checkbox
    - checkbox\_multiple
    - radio
4. `relationship`: This is needed in case of a select, select\_multiple, radio or checkbox\_multiple buttons. You can state here the name of the relationship as it is defined in the model. In the example bellow, the `Post` model has a `belongsTo` relationship to `category` and a `belongsToMany` relationship to `tags`. For `belongsTo` relationships you can use a select or a radio(group of radios) input. For `belongsToMany` relationships you can use a select\_multiple or checkbox\_multiple inputs.
5. `relFieldName`: This is optional. It is used only in case we have a relationship, to set the name of the attribute of the related model that is displayed (ie. in a select's options). If not defined, the default attribute to be used is `name`.

```
$this->formFields = [
    ['name' => 'title', 'label' => 'Title', 'type' => 'text'],
    ['name' => 'slug', 'label' => 'Slug', 'type' => 'text'],
    ['name' => 'body', 'label' => 'Enter your content here', 'type' => 'textarea'],
    ['name' => 'publish_on', 'label' => 'Publish Date', 'type' => 'date'],
    ['name' => 'published', 'label' => 'Published', 'type' => 'checkbox'],
    ['name' => 'category_id', 'label' => 'Category', 'type' => 'select', 'relationship' => 'category'],
    ['name' => 'tags', 'label' => 'Tags', 'type' => 'select_multiple', 'relationship' => 'tags'],
];
```

### The `indexFields` array

[](#the-indexfields-array)

These are the model's attributes that are displayed in the index page.

```
$this->indexFields = ['title', 'category_id', 'published'];
```

If not defined, then the first of the `formFields` is shown.

### The `formTitle` (optional)

[](#the-formtitle-optional)

You can optionally, define the name of the model as we want it to appear in the views. If not defined, the name of the model will be used.

### The `bladeLayout` (optional)

[](#the-bladelayout-optional)

This is used to define the blade layout file that will be extended by the views for the crud forms and index page.

### The option to display deleted models (`withTrashed`)

[](#the-option-to-display-deleted-models-withtrashed)

Setting this to true, will also display deleted models and offer an option to restore them.

```
$this->withTrashed = true;
```

In order to be able to restore the models, you need to define an additional route:

```
Route::put('posts/{post}/restore', [PostController::class, 'restore'])->name('posts.restore');
```

### The `validationRules` array (optional)

[](#the-validationrules-array-optional)

These are the rules we want to use to validate data before saving the model.

```
$this->validationRules = [
    'title'       => 'required|max:255',
    'slug'        => 'required|max:100',
    'body'        => 'required',
    'publish_on'  => 'date',
    'published'   => 'boolean',
    'category_id' => 'required|int',
];
```

### The `validationMessages` array (optional)

[](#the-validationmessages-array-optional)

Use this to define custom messages for validation errors. For example:

```
$this->validationMessages = [
    'body.required' => "You need to fill in the post content."
];
```

### The `validationAttributes` array (optional)

[](#the-validationattributes-array-optional)

Use this to change the way an attribute's name should appear in validation error messages.

```
$this->validationAttributes = [
    'title' => 'Post title'
];
```

Views and themes
----------------

[](#views-and-themes)

The package ships with two view sets ("themes") so the forms match whatever your app uses:

- **`bootstrap`** *(default)* — Bootstrap 3 markup. Kept as the default for backwards compatibility. It expects Bootstrap 3 CSS (and, if `button_icons` is enabled, Font Awesome) to be loaded by your app's layout.
- **`tailwind`** — Tailwind CSS markup with inline SVG icons (no Font Awesome dependency). The bundled layout pulls Tailwind from the Play CDN so it looks styled out of the box; in production you should use your app's compiled Tailwind (set `crud-forms.blade_layout` to your own layout, or publish and edit the bundled one).

### Choosing a theme (no publishing required)

[](#choosing-a-theme-no-publishing-required)

Publish the config file and set the `theme` option:

```
php artisan vendor:publish --provider="Achillesp\CrudForms\CrudFormsServiceProvider" --tag=config

```

```
// config/crud-forms.php
'theme' => 'tailwind', // or 'bootstrap' (default)
```

That's all that's needed to switch the rendered forms — you do **not** have to publish the views.

### Publishing views for customisation

[](#publishing-views-for-customisation)

If you want to edit the markup yourself, publish a theme's views. Both sets publish to `resources/views/vendor/crud-forms`, and **published views always take precedence** over the `theme` setting above.

```
# Bootstrap 3 views
php artisan vendor:publish --provider="Achillesp\CrudForms\CrudFormsServiceProvider" --tag=views

# Tailwind views
php artisan vendor:publish --provider="Achillesp\CrudForms\CrudFormsServiceProvider" --tag=views-tailwind

```

Because both sets publish to the same folder, only one can be published at a time. To switch the published set, add `--force` (or delete `resources/views/vendor/crud-forms` first). Publish by `--tag`, not by `--provider`alone, so you copy exactly one view set.

### Which views are used? (precedence)

[](#which-views-are-used-precedence)

1. Published views in `resources/views/vendor/crud-forms`, if present.
2. Otherwise, the bundled view set chosen by `crud-forms.theme`.

### JavaScript hooks

[](#javascript-hooks)

Both themes keep CSS classes for common JavaScript libraries:

- `select2` on select inputs
- `datepicker` on date inputs
- `data-table` on the index table

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for the release history.

License
-------

[](#license)

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

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance65

Regular maintenance activity

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 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.

###  Release Activity

Cadence

Every ~177 days

Recently: every ~283 days

Total

14

Last Release

842d ago

Major Versions

1.1.2 → v2.x-dev2019-09-24

1.1.3 → 3.02020-10-13

3.1.1 → 4.02023-02-03

4.0 → 5.02023-02-03

5.0 → 6.02024-03-14

PHP version history (5 changes)1.0PHP ^7.0

v2.x-devPHP ^7.2

4.0PHP ^7.3|^8.0

5.0PHP ^8.0.2

6.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5294270?v=4)[Achilles Panagiotou](/maintainers/achillesp)[@achillesp](https://github.com/achillesp)

---

Top Contributors

[![achillesp](https://avatars.githubusercontent.com/u/5294270?v=4)](https://github.com/achillesp "achillesp (31 commits)")

---

Tags

crudeloquentformslaravellaravel-packagelaraveleloquentcrudForms

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/achillesp-laravel-crud-forms/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[prettus/l5-repository

Laravel 8|9|10|11|12|13 - Repositories to the database layer

4.3k11.3M157](/packages/prettus-l5-repository)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.9k1](/packages/mike-bronner-laravel-model-caching)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)

PHPackages © 2026

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