PHPackages                             wkasunsampath/laravel-autocrud - 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. [Framework](/categories/framework)
4. /
5. wkasunsampath/laravel-autocrud

ActiveLibrary[Framework](/categories/framework)

wkasunsampath/laravel-autocrud
==============================

Automate CRUD operations in Laravel applications.

v1.2.9(3y ago)233853MITPHPPHP ^8.0

Since Dec 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/wkasunsampath/laravel-autocrud)[ Packagist](https://packagist.org/packages/wkasunsampath/laravel-autocrud)[ Docs](https://github.com/wkasunsampath/laravel-autocrud)[ RSS](/packages/wkasunsampath-laravel-autocrud/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (12)Used By (0)

Laravel Autocrud - Automate CRUD operations in Laravel applications.
====================================================================

[](#laravel-autocrud---automate-crud-operations-in-laravel-applications)

[![Latest Stable Version](https://camo.githubusercontent.com/e5f5f82beaf9c0cd4e6750063921da0933d9553cfd1f8079809634133f821b77/687474703a2f2f706f7365722e707567782e6f72672f776b6173756e73616d706174682f6c61726176656c2d6175746f637275642f76)](https://packagist.org/packages/wkasunsampath/laravel-autocrud) [![License](https://camo.githubusercontent.com/c5cbb92d52fdfd526827f0486e17d4e0247d32bcc5cd24e6ec7f865faba52ef4/687474703a2f2f706f7365722e707567782e6f72672f776b6173756e73616d706174682f6c61726176656c2d6175746f637275642f6c6963656e7365)](https://packagist.org/packages/wkasunsampath/laravel-autocrud) [![PHP Version Require](https://camo.githubusercontent.com/265aa5bdcf90cbbc516e412a537368fa945133cb86eaeed5dcb79389756bbf38/687474703a2f2f706f7365722e707567782e6f72672f776b6173756e73616d706174682f6c61726176656c2d6175746f637275642f726571756972652f706870)](https://packagist.org/packages/wkasunsampath/laravel-autocrud)

When Laravel apps are developed, developers have to write CRUD operations for several models. Some of them are just regular CRUD operations without any special logic. This package is to automate these CRUD operations. Therefore, developers can save most of their development time.

To create a fully working CRUD for User model, just run below command,

```
php artisan autocrud:create User
```

All you have to do is that. :) Now your Laravel app have below routes registered. To see routes, run `php artisan route:list`.

MethodRouteRoute NameOperationGet/usersusers\_indexIndexGet/users/{id}users\_viewViewPost/usersusers\_createCreatePut/users/{id}users\_updateUpdateDelete/users/{id}users\_deleteDeleteSeems interesting? :D Ok!, let's continue.

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

[](#installation)

You can install the package via composer: (Currently supports only for Laravel 8, 9 &amp; 10)

```
composer require wkasunsampath/laravel-autocrud
```

You can publish assets and config with:

```
php artisan autocrud:install
```

All done. Now you can see there is a `autocrud.php` file in config folder. Also, there is a new folder called Autocruds in `\App\Http` folder.

Usage
-----

[](#usage)

Let's assume that there is a model called `Office` at `\App\Models\Company\Office.php`. To create a fully working CRUD for that model, just run,

```
php artisan autocrud:create Company/Office
```

All done. Your CRUD is working now. Not sure? Ok!, just run `php artisan route:list`.

> ***NOTE:*** It is recommanded to maintain the same structure inside Autocruds folder as inside models folder.

Let's go deeper.

### Docs

[](#docs)

- [Autocrud Classes](#autocrud-classes)
- [Configuration](#configuration)
- [Folder Structure](#folder-structure)
- [Index Route](#index-route)
- [View Route](#view-route)
- [Create Route](#create-route)
- [Update Route](#update-route)
- [Delete Route](#delete-route)
- [Best Practices](#best-practices)

Autocrud Classes
----------------

[](#autocrud-classes)

Autocrud classes are the files generated when runs `php artisan autocrud:create {class_name}`. Normally, these files are stored in `\App\Http\Autocruds` folder.

Autocruds classes extend the BaseCrud class. Most important setting of this class is `protected string $model`. You can bind the model which you need to create CRUD here. It is recommanded to use the model name as the Autocrud class name.

```
