PHPackages                             rashidhamidov/model-form - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. rashidhamidov/model-form

ActivePackage[Utility &amp; Helpers](/categories/utility)

rashidhamidov/model-form
========================

Dynamic Model Form for crate form automaticaly from model fields

2.0.0(1y ago)134MITBladePHP ^8.0

Since Dec 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rashidhamidov/model-form)[ Packagist](https://packagist.org/packages/rashidhamidov/model-form)[ RSS](/packages/rashidhamidov-model-form/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

Laravel Model Form Package
--------------------------

[](#laravel-model-form-package)

This is package is for create dynamic crud forms for model.

- **Laravel 8** is supported

```
composer require rashidhamidov/model-form

```

These advantages are

- Create Dynamic Forms from Model file with one function
- Create Rules in Model file with one function
- Automatically Creates Forms which you want
- You can change the class names and can add more than one class name into form element

#### Inserting Trait to Model

[](#inserting-trait-to-model)

```
class Product extends Model
{
    use HasCrudForm;
}
```

#### Abstract Functions

[](#abstract-functions)

*setRootName() and setRules() is a mandatory functions for models that extends HasCrudForm trait*

You have to override this functions for form post and request validation. If you set root name as product the form action will be route with names:

- product.store
- product.update

It automatically gets the model data id from your send with form function

```
private function setRootName()
    {
        return "product";
    }

private function setRulesStore()
    {
        return [
            'name'=>"required"
        ];
    }
private function setRulesUpdate()
    {
        return [
            'name'=>"required"
        ];
    }
```

#### Make Form Fields

[](#make-form-fields)

There is a function for create form *formFields()* and returns an array. You can create form like this.

```
protected function formFields()
    {
        return [
            "name" => $this->setInputField('name', 'text', 'form-control', true, ''),
            "gender" => $this->setInputField('gender', 'radio', 'form-control', true, '', ["Male" => 'male', "Female" => "female"]),
            "phone" => $this->setInputField('phone', 'text', 'form-control phone-mask', false, ''),
            "detail" => $this->setTextAreaField('detail', 'form-control richtext', false, ''),
            "status" => $this->setSelectField('status', 'form-control', true, '', ['True'=>1, 'False'=>0]),
            "user" => $this->setForeignField('id','email','user_id', 'form-control', true, '', User::all()->toArray()),
            "date" => $this->setInputField('date', 'date', 'form-control', false, ''),
            "time" => $this->setInputField('time', 'time', 'form-control', false, ''),
        ];
    }
```

There are three type of elements and full type of those elements in form. You can also set className into array and required fields. In select filed you have to set array into array that values in it.

### Call Form Function

[](#call-form-function)

```
$model = new Product();
```

Into your blade file *form()* function returns a views that comprise form of Model.

```
{{$model->form()}}
```

For Model Update Form you have to send model as variable which you want to change.

```
$model = Product::find($id);
$model->form($model);
```

Before use *form()* function you have to define in your web.php file Model Controller Route resource or store and update routes for store and update routes

```
Route::resource('product',ProductController::class);
//or
Route::post('/product',[ProductController::class,'store'])->name('product.store')
Route::put('/product/{product}',[ProductController::class,'update'])->name('product.store')
```

### Rules Usage

[](#rules-usage)

After define rules you can use validation with this rule array

```
public function store(Request $request)
    {
        $model = new Product();
        $request->validate($model->getRules());
    }
```

License
-------

[](#license)

This package is developed by Rashid Hamidov for Laravel framework [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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 ~608 days

Total

2

Last Release

687d ago

Major Versions

1.0.1 → 2.0.02024-08-16

### Community

Maintainers

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

---

Top Contributors

[![rashidhamidov](https://avatars.githubusercontent.com/u/71139681?v=4)](https://github.com/rashidhamidov "rashidhamidov (30 commits)")

---

Tags

laraveldynamic formmodel-formform-rulecrud-form

### Embed Badge

![Health badge](/badges/rashidhamidov-model-form/health.svg)

```
[![Health](https://phpackages.com/badges/rashidhamidov-model-form/health.svg)](https://phpackages.com/packages/rashidhamidov-model-form)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M10](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k12.5k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90142.9k](/packages/emargareten-inertia-modal)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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