PHPackages                             atcliff/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. atcliff/laravel-crud-forms

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

atcliff/laravel-crud-forms
==========================

Create CRUD Forms for Laravel Models.

3.0(6y ago)09.9kMITPHPPHP ^7.2

Since Nov 19Pushed 6y agoCompare

[ Source](https://github.com/AtCliffUnderline/laravel-crud-forms)[ Packagist](https://packagist.org/packages/atcliff/laravel-crud-forms)[ RSS](/packages/atcliff-laravel-crud-forms/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (11)Used By (0)

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

[](#laravel-crud-forms)

This is a Laravel &gt;=5.5 package to help easily create CRUD (Create, Read, Update, Delete) forms for eloquent models (as well as an index page). It aims to be used as a quick tool which does not interfere with the other parts of the application that it's used in.

The package provides:

- A trait to use in resource controllers and
- A series of views for displaying the forms

The views are built using bootstrap (v3), but the styling can easily be overriden.

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 routes:

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

### 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\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', ['as' => 'posts.restore', 'uses' => 'PostController@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
-----

[](#views)

The views are built with bootstrap v.3 and also have css classes to support some common JavaScript libraries.

- select2 class is used in select inputs
- datepicker class is used in date inputs
- data-table class is used in the index view table

It is also possible to publish the views, so you can change them anyway you need. To publish them, use the following artisan command:

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

```

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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 ~94 days

Recently: every ~20 days

Total

9

Last Release

2339d ago

Major Versions

1.1.2 → 2.02019-09-24

1.1.3 → 2.12019-10-25

2.1 → 3.02019-12-17

PHP version history (2 changes)1.0PHP ^7.0

2.0PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/15dfa03ac5bc649e224cf12da34c24115735f27f865a26e2eea3e57c75dfde68?d=identicon)[AtCliff\_](/maintainers/AtCliff_)

---

Top Contributors

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

---

Tags

laraveleloquentcrudForms

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)[relaticle/custom-fields

User Defined Custom Fields for Laravel Filament

15828.6k](/packages/relaticle-custom-fields)[achillesp/laravel-crud-forms

Create CRUD Forms for Laravel Models.

375.5k](/packages/achillesp-laravel-crud-forms)[kalnoy/cruddy

Backend interface for handling CRUD operations on your Laravel Eloquent models.

1635.0k2](/packages/kalnoy-cruddy)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121130.3k](/packages/highsolutions-eloquent-sequence)[cybercog/laravel-nova-ban

A Laravel Nova banning functionality for your application.

40199.8k](/packages/cybercog-laravel-nova-ban)

PHPackages © 2026

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