Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Crud Bundle Laravel Package

araise/crud-bundle

View on GitHub
Deep Wiki
Context7

Table Configuration

For a basic table configuration refer to the araiseTableBundle Documentations

class LocationDefinition extends AbstractDefinition
{
    // ...

    public function configureTable(Table $table)
    {
        $table
            ->addColumn(
                'name', 
                null, [
                    'label' => 'Name',
                ]
            )
            ->addColumn('zip', null, ['label' => 'ZIP']);
    }

    // ...
}

Filter with joins

It is possible to create filters based on columns that have to be joined.
FilterTypes accept an array of filters.

Automatically added Filters

By default, the bundle tries to generate filters for you. But this doesn't work in all cases. That's why you should always check the filters and fix or remove the broken ones.

Remove an automatically generated filter

You can let the CrudBundle handle the generation of filters and remove some of them like this:

public function configureFilters(Table $table): void
{
    parent::configureFilters($table);

    $table->getFilterExtension()?->removeFilter('id');
}

Custom Filters

Simple

Filter all rooms included in a house with a specific color.
This filter would be applied on the RoomDefinition.

public function configureFilters(Table $table): void
{
    parent::configureFilters($table);
    $filterExtension = $table->getFilterExtension();

    $filterExtension->addFilter('roofColor', 'Roof Color',
        new AjaxRelationFilterType('houseRoof.color', HouseColor::class, $this->doctrine,
            [
                'house' => self::getQueryAlias().'house',
                'houseRoof' => 'house.roof'
            ]
        )
    );
}

Advanced

In this example we join a ManyToOne (Room -> House) and then a OneToMany (House -> Furniture) relation.
The goal is to filter all rooms contained in all houses which include furniture with a specific status (StatusEnum).
This filter would be applied on the RoomDefinition as well.

public function configureFilters(Table $table): void
{
    parent::configureFilters($table);
    $filterExtension = $table->getFilterExtension();

    $filterExtension->addFilter('houseIncludesFurniture', 'House includes furniture', new SimpleEnumFilterType('houseFurniture.status', [
        'house' => ['innerJoin', self::getQueryAlias().'.house'],
        'houseFurniture' => ['innerJoin', Furniture::class, 'WITH', 'houseFurniture.house = house.id'],
    ], FurnitureStatus::class));
}

Action Buttons

The CrudBundle will add two Action Buttons to each row (show / edit). To add more use the same method configureTableActions.

public function configureTableActions(Table $table): void
{
    parent::configureTableActions($table);
    
    $table->addAction('acronym', [
        Action::OPT_ICON => 'icon',
        Action::OPT_LABEL => 'label',
        Action::OPT_ROUTE => 'route',
    ]);
}

Where:

  • icon = fa icon suffix (for "fa-clone" just write "clone")
  • label = the text on the button
  • route = route name (CrudBundle will pass the entity "id" to the route generator)

Actions that need an entity

If you need access on the data of the entity to build your route (for example because you need the ID in the route parameters), you can use the configureActions method.

You can find an example here.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware