mariojgt/builder

Laravel Crud builder with dynamic tables and controller made in vue js

Installs: 45

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:Vue

Type:package

1.1.2 2023-10-01 10:01 UTC

This package is auto-updated.

Last update: 2024-04-18 15:54:44 UTC


README

image info

Builder

Introducing our Laravel package, the perfect solution for quickly building generic CRUD operations in your project. With just a few simple commands, you can easily generate boilerplate code for creating, reading, updating, and deleting data in your database. Our package is designed to be flexible and customizable, allowing you to easily make adjustments to fit your project's specific requirements. Say goodbye to tedious manual coding and save precious development time with our powerful and intuitive package.

Features

  • Ready to use database crud api integrated with laravel.
  • Dynamic form builder.

Requirements

  • Laravel.
  • Tailwind.
  • Daisy ui.
  • Inersia js.

First option via composer

  1. composer require mariojgt/builder
  2. php artisan install::builder

This will copy the resource assets, run migrations and copy over some config file we need to use;

How to use

1: Go to the routes file and you first need to add the following line:

    // Table api controller in where you can use your middleware
    Route::controller(TableBuilderApiController::class)->group(function () {
        Route::post('/admin/api/generic/table', 'index')->name('admin.api.generic.table');
        Route::post('/admin/api/generic/table/create', 'store')->name('admin.api.generic.table.create');
        Route::post('/admin/api/generic/table/update', 'update')->name('admin.api.generic.table.update');
        Route::post('/admin/api/generic/table/delete', 'delete')->name('admin.api.generic.table.delete');
    });

2: in you controller you need the following array

        // Table columns
        $columns = [
            [
                'label'     => 'Id',    // Display name
                'key'       => 'id',    // Table column key
                'sortable'  => true,    // Can be use in the filter
                'canCreate' => false,   // Can be use in the create form
                'canEdit'   => false,   // Can be use in the edit form
            ],
            [
                'label'     => 'Name',   // Display name
                'key'       => 'name',   // Table column key
                'sortable'  => true,     // Can be use in the filter
                'canCreate' => true,     // Can be use in the create form
                'canEdit'   => true,     // Can be use in the edit form
                'type'      => 'text',   // Type text,email,password,date,timestamp
            ],
            [
                'label'     => 'Guard',
                'key'       => 'guard_name',
                'sortable'  => true,
                'canCreate' => true,
                'canEdit'   => true,
                'type'      => 'text',
            ],
            [
                'label'     => 'Created At',
                'key'       => 'created_at',
                'sortable'  => false,
                'canCreate' => false,
                'canEdit'   => true,
                'type'      => 'date',
            ],
            [
                'label'     => 'Updated At',
                'key'       => 'updated_at',
                'sortable'  => false,
                'canCreate' => false,
                'canEdit'   => true,
                'type'      => 'timestamp',
            ],
        ];

        return Inertia::render('BackEnd/Role/Index', [
            'title' => 'Role | Roles',
            // Required for the Builder Generic table api
            'endpoint'       => route('admin.api.generic.table'),
            'endpointDelete' => route('admin.api.generic.table.delete'),
            'endpointCreate' => route('admin.api.generic.table.create'),
            'endpointEdit'   => route('admin.api.generic.table.update'),
            // You table columns
            'columns'        => $columns,
            // The model where all those actions will take place
            'model'          => encrypt(Role::class),
            // If you want to protect your crud form you can use this below not required
            'permission'     => encrypt([ // Must be encrypted
                'guard'          => 'skeleton_admin',
                // You can use permission or role up to you
                'type'          => 'permission',
                // The permission name or role
                'key' => [
                    'store'  => 'create-permission',
                    'update' => 'edit-permission',
                    'delete' => 'delete-permission',
                    'index'  => 'read-permission',
                ],
            ]),
        ]);