PHPackages                             macropay-solutions/laravel-crud-wizard-decorator-free - 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. [Admin Panels](/categories/admin)
4. /
5. macropay-solutions/laravel-crud-wizard-decorator-free

ActiveLibrary[Admin Panels](/categories/admin)

macropay-solutions/laravel-crud-wizard-decorator-free
=====================================================

Data composition/decoration for laravel-crud-wizard-free library including url query language

2.0.3(3mo ago)315211MITPHPPHP ^8.0CI passing

Since Mar 26Pushed 1w ago1 watchersCompare

[ Source](https://github.com/macropay-solutions/laravel-crud-wizard-decorator-free)[ Packagist](https://packagist.org/packages/macropay-solutions/laravel-crud-wizard-decorator-free)[ RSS](/packages/macropay-solutions-laravel-crud-wizard-decorator-free/feed)WikiDiscussions production Synced 1mo ago

READMEChangelog (10)Dependencies (20)Versions (20)Used By (1)

laravel-crud-wizard-decorator-free
==================================

[](#laravel-crud-wizard-decorator-free)

[![Build Status](https://github.com/macropay-solutions/laravel-crud-wizard-decorator-free/actions/workflows/tests.yml/badge.svg)](https://github.com/macropay-solutions/laravel-crud-wizard-decorator-free/actions)[![Total Downloads](https://camo.githubusercontent.com/470ec694082eae517b79f3392ab9c3518855ab9c17acd296e92671d6e521aaf2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6163726f7061792d736f6c7574696f6e732f6c61726176656c2d637275642d77697a6172642d6465636f7261746f722d66726565)](https://packagist.org/packages/macropay-solutions/laravel-crud-wizard-decorator-free)[![Latest Stable Version](https://camo.githubusercontent.com/04a17a2000ff2cb101a8040039a1601152976246ee73f4ff9b5b1b63b6d5a829/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6163726f7061792d736f6c7574696f6e732f6c61726176656c2d637275642d77697a6172642d6465636f7261746f722d66726565)](https://packagist.org/packages/macropay-solutions/laravel-crud-wizard-decorator-free)[![License](https://camo.githubusercontent.com/2201e2d448ab8ab4fc1bb0b15acd6032b63c52413910d8367508cf4ed9dd4500/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6163726f7061792d736f6c7574696f6e732f6c61726176656c2d637275642d77697a6172642d6465636f7261746f722d66726565)](https://packagist.org/packages/macropay-solutions/laravel-crud-wizard-decorator-free)

It renames/maps the column names for the resource and its relations.

The reserved words / parameters that will be used as query params are:

- perPage
- page

The `withRelations, withRelationsCount, withRelationsExistence` query params will be disregarded

I. [Install](#i-install)

II. [Start using it](#ii-start-using-it)

III. [Crud routes](#iii-crud-routes)

III.1. [Create resource](#iii1-create-resource)

III.2. [Get resource](#iii2-get-resource)

III.3. [List filtered resource](#iii3-list-filtered-resource)

III.4. [Update resource (or create)](#iii4-update-resource-or-create)

III.5. [Delete resource](#iii5-delete-resource)

I. Install
----------

[](#i-install)

```
composer require macropay-solutions/laravel-crud-wizard-decorator-free

```

II. Start using it
------------------

[](#ii-start-using-it)

Register your middleware decorators as route middleware for each resource:

```
    $app->routeMiddleware([
        'decorate-' . \MacropaySolutions\LaravelCrudWizardDecorator\Models\ExampleModel::resourceName()=>
            MacropaySolutions\LaravelCrudWizardDecorator\Http\Middleware\Decorators\ExampleMiddleware::class,
    ]);
```

OBS.

- The `withRelations, withRelationsCount, withRelationsExistence` query params will be disregarded. These are to be used only internally with undecorated request.
- 202 http response code will not be decorated, and it can be used to send messaged to FE. Example: {"message":"Accepted"}
- 204 http response will be decorated as empty body.

Use the middleware alias as middleware in your crud route definition for each method if you have only few routes:

```
    'decorate-' . $resourceName . ':list'
    'decorate-' . $resourceName . ':get'
    'decorate-' . $resourceName . ':getRelated'
    'decorate-' . $resourceName . ':update'
    'decorate-' . $resourceName . ':updateRelated'
    'decorate-' . $resourceName . ':create'
    'decorate-' . $resourceName . ':delete'
    'decorate-' . $resourceName . ':deleteRelated'
```

If you have many routes that need decoration, it is faster to use the middleware FQN directly in the route definition:

```
    SomeMiddleware::class . ':list'
    ...
```

In this way you avoid loading on each request the route middleware array that in some cases can become quite big (hundreds of elements).

Coupled with cached routes this solution is faster than the initial suggested one.

Example:

```
