PHPackages                             mmstfkc/basic-crud - 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. mmstfkc/basic-crud

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

mmstfkc/basic-crud
==================

This structure is designed for use in basic CRUD operations.

v1.0.3(2y ago)0121[7 issues](https://github.com/mmstfkc/basic-crud/issues)MITPHP

Since Dec 11Pushed 2y ago1 watchersCompare

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

READMEChangelog (3)DependenciesVersions (6)Used By (0)

You should run the following command for installation of the project.

```
  composer require mmstfkc/basic-crud
```

Copy Config File

```
  cp vendor/mmstfkc/basic-crud/src/config/basicCrud.php config
```

(Optional) If you want the error messages to be displayed as in the package, you can follow the steps below.

Go to the file below and add the commands.

app/Exceptions/Handler.php:56

```
    protected $dontReport = [
        ...
        BasicCrudException::class
    ];

    public function render($request, Throwable $e): Response|JsonResponse
    {
        [$message, $statusCode, $code, $errors] = $this->getBasicCrudExceptionExceptionFields($e);

        if (App::environment() == 'production') {
            $errors = '';
        }

        return response()->json(
            [
                'status' => false,
                'code' => $code,
                'errors' => $errors,
                'message' => $message,
            ],
            $statusCode
        );
    }

    private function getBasicCrudExceptionExceptionFields(Throwable $exception): array
    {
        $errors = $exception->getMessage();
        $message = Str::snake(class_basename($exception));
        $statusCode = 500;
        $code = 1008;

        switch (get_class($exception)) {
            case BasicCrudException::class:
                $message = 'validation';
                $errors = $exception->getErrors();
                $statusCode = 422;
                $code = 1002;
                break;
        }

        return [
            $message,
            $statusCode,
            $code,
            $errors,
        ];
    }
```

Usage of the Package
====================

[](#usage-of-the-package)

After completing the package installation, the necessary steps to follow are as follows:

Controller
----------

[](#controller)

We create a controller and extend ModelController class to these controllers.

⚠️ModelController is extended from "App\\Http\\Controllers\\Controller" located in your own directory. Any changes you make there will affect the package. ⚠️

Example of your Controller file can be as follows.

```
