PHPackages                             bushart/crudmagic - 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. bushart/crudmagic

ActiveLibrary[Framework](/categories/framework)

bushart/crudmagic
=================

A simple modified crud package

1.4.2(2y ago)160MITPHP

Since Apr 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/busharthussain/crudmagic)[ Packagist](https://packagist.org/packages/bushart/crudmagic)[ RSS](/packages/bushart-crudmagic/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (9)Used By (0)

Laravel-magic-Crud
==================

[](#laravel-magic-crud)

*If you want to save time on your crud operations*

This Laravel package is for saving time on CRUD operations when used in combination with Repositories or Services. The trait covers the basics needed for running simple CRUD operations. It also comes with a Contract that you can bind to your services via automated contextual binding.

### Docs

[](#docs)

- [Installation](#installation)
- [Configuration](#configuration)
- [Generators](#generators)

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

[](#installation)

Here is the complete video of the usage and installation of the package.

[ ![Laravel magic](video/thumbnail.png)](https://www.youtube.com/watch?v=TMF2bbvme74)### Install package

[](#install-package)

Add the package in your composer.json by executing the command.

```
composer require bushart/crudmagic

```

Next, add the service provider to `app/config/app.php`

```
bushart\crudmagic\MagicServiceProvider::class,

```

Configuration
-------------

[](#configuration)

### Publish configuration files

[](#publish-configuration--files)

Laravel 8.\*

```
php artisan vendor:publish --tag=public

```

```
php artisan vendor:publish --tag=config

```

### Namespace for resource controllers

[](#namespace-for-resource-controllers)

If you wish to set a default namespace for resource controllers use this option. Which will be used when in silent mode in the resource generator.

```
'default_resource' => 'Admin',

```

Generators
----------

[](#generators)

### Controller Generator

[](#controller-generator)

You can generate either a blank controller or a complete resource controller.

```
php artisan magic:controller YourControllerName

```

This will generate the resource controllers with all necessary basic functions already filled in for you based on the Crudable functionality.

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Exception;
use bushart\crudmagic\CrudHelpers;
use App\Models\YourModelName;

class YourControllerName extends Controller
{
    protected $orders;
    private $data, $params = [];
    private $success = false;
    private $message = '';

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $this->data['headers'] = $this->headers();

        return view('admin.yourResourceName.index', $this->data);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.yourResourceName.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $data = $request->all();
        if (!empty($data)) {
            unset($data['token']);
            if ($request->hasFile('Your file input name')) {  // If you want to upload image
                $path = 'Your public path';
                $returnArray = CrudHelpers::uploadImage($request, 'your file input name', $path); // This function return a file name and file original name, you can use it as needed.
            }
            YourModelName::create($data);
            $this->success = true;
            $this->message = 'Data created successfully';
        }

        return response()->json(['success' => $this->success, 'message' => $this->message]);
    }

    /**
     * Display the specified resource.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        return view('admin.orders.show');
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $this->data['data'] = YourModelName::find($id);

        return view('admin.yourResourceName.edit', $this->data);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $data = $request->all();
        $obj = YourModelName::find($id);
        if (!empty($obj)) {
            $obj->update($data);
            $this->success = true;
            $this->message = 'Data updated successfully';
        }

        return response()->json(['success' => $this->success, 'message' => $this->message]);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $obj = YourModelName::find($id);
        if (!empty($obj)) {
            $obj->delete();
            $this->success = true;
            $this->message = 'Data deleted successfully';
        }

        return response()->json(['success' => $this->success, 'message' => $this->message]);
    }

    /**
     * This is use to get data.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function getData(Request $request)
    {
        $this->data = [];
        $this->params = [
            'perPage' => 10, // use to paginate data per page by default it is 10.
            'page' => $request->input('page'),
            'search' => $request->input('search'),
            'sortColumn' => $request->input('sortColumn'),
            'sortType' => $request->input('sortType'),
            'dropDownFilters' => $request->input('dropDownFilters'),
        ];
        $this->data = YourModelName::getData($this->params);

        return response()->json($this->data);
    }

    /**
     * this is use to function create table header name
     *
     * @return array
     */
    protected function headers()
    {
         /*========================================
          Here we use the test header names.
          You can use the header names as you want.

          In the action header, we use false for the sorting because we do not sort on the actions.
          so the headers or the columns you do not want to sort just add false in the third place.
          For example: ['Action', '', false].
          For the header names if they are different from the Order column name, For example:
          The column name in the table is Name and you want to use "Header name 1" in the header so for sorting you should have to add the Order column name.
          Like: ['Header name 1', 'name'],
        ==========================================*/
        $array = [
            ['Header name 1'], ['Header name 2'], ['Action', '', false]
        ];

        return CrudHelpers::generateHeaders($array);
    }
}

```

This of course only covers the very basic functions but saves you from writing the same boiler plate code over and over again.

If you just need a blank controller with just the services implemented use the blank option like so:

```
php artisan magic:controller --blank

```

### View Generator

[](#view-generator)

You can generate basic views for create/edit/index based on the Bootstrap version that shipped with Laravel.

```
php artisan magic:views YourModelName

```

### Resource Generator

[](#resource-generator)

If you're starting out fresh you may wish to generate the entire resource including the model, service, resource controller Route and views .

```
php artisan magic:resource YourResourceName

```

### Note

[](#note)

Please make sure that you use the jquery version ^3.0. If you do not include jquery in your main blade so please put this in your main blade with Javascript libraries.

```

```

Have fun CRUDding! :-)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.6% 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 ~30 days

Total

8

Last Release

906d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c8f197be03f87ca7ebfb567da963b7310d8cf259148758fac79345b24a567f1?d=identicon)[busharthussain](/maintainers/busharthussain)

---

Top Contributors

[![busharthussain](https://avatars.githubusercontent.com/u/12028370?v=4)](https://github.com/busharthussain "busharthussain (11 commits)")[![WaqarHussainKhalid](https://avatars.githubusercontent.com/u/52109661?v=4)](https://github.com/WaqarHussainKhalid "WaqarHussainKhalid (3 commits)")

### Embed Badge

![Health badge](/badges/bushart-crudmagic/health.svg)

```
[![Health](https://phpackages.com/badges/bushart-crudmagic/health.svg)](https://phpackages.com/packages/bushart-crudmagic)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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