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

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

waqar/crudmagic
===============

A simple modified crud package

1.0(2y ago)03MITPHP

Since May 13Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)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 waqar/crudmagic

```

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

```
waqar\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 waqar\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']);
            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($data['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

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

1093d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/04b5f5b3815b9dd159be6a09489fd518d1b500eb8c4c250795105b2965da4222?d=identicon)[WaqarHussainKhalid](/maintainers/WaqarHussainKhalid)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[laracademy/generators

This package will generate a Laravel Model based on your database table itself, filling in the required fields automatically.

355346.4k4](/packages/laracademy-generators)[beyondcode/laravel-vouchers

Allow users to redeem vouchers that are bound to models..

70763.4k2](/packages/beyondcode-laravel-vouchers)[firegento/magesetup2

MageSetup provides the necessary configuration (system config, tax, agreements, etc. for a national market.

123328.5k1](/packages/firegento-magesetup2)[sixlive/nova-text-copy-field

Laravel Nova text field with click to copy support

70708.2k2](/packages/sixlive-nova-text-copy-field)[happyr/message-serializer

Serialize classes the good way.

80491.3k](/packages/happyr-message-serializer)[percymamedy/laravel-dev-booter

Boost your Laravel app by registering Prod services only on Prod.

35320.7k1](/packages/percymamedy-laravel-dev-booter)

PHPackages © 2026

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