LaravelPackages.net
Acme Inc.
Toggle sidebar
nimesh143/crudbooster

CRUDBooster Is CRUD Generator Based On Laravel Easy To Make An Advanced Backend

4
1
v5.4.20
About nimesh143/crudbooster

nimesh143/crudbooster is a Laravel package for crudbooster is crud generator based on laravel easy to make an advanced backend. It currently has 1 GitHub stars and 4 downloads on Packagist (latest version v5.4.20). Install it with composer require nimesh143/crudbooster. Discover more Laravel packages by nimesh143 or browse all Laravel packages to compare alternatives.

Last updated

CRUDBOOSTER DEVELOPMENT

Do not use this master repository for production

Table Of Index

  1. Installation
  2. Quick Start
  3. Basic Code Knowledge
  4. Type Available
    1. Text
    2. Checkbox
    3. Password
    4. Image
    5. Text Area
    6. Select
    7. Custom
    8. Date
    9. Date & Time
    10. Email
    11. Money
    12. File Upload
    13. Hidden Input
    14. Number
    15. Radio Button
    16. WYSIWYG
  5. Additional Basic Options
  6. Show Column To Specific Page
  7. Buttons Display Control
  8. Additional View
  9. Additional Index Head Buttons
  10. Additional Table Grid Action Buttons
  11. Hide Buttons With Condition
  12. Command Artisan Available
  13. Module Helper Available
  14. FCM Google Push Notification

Installation

Make sure you have installed newest laravel

composer require crocodicstudio/crudbooster=dev-master

Then don't forget to run the crudbooster installation command :

php artisan crudbooster:install

Quick Start

Whatever you want to use laravel artisan serve or xampp . I assume you can go to the default crudbooster path /developer/login

Little different? yep. For the first time, you need to make your some modules, menus, and users for your new backend.

Developer Area :
default path : /developer/login
default user : developer
default pass : You will get once the installation is finished

WARNING PLEASE DON'T FORGET TO CHANGE THE DEFAULT DEVELOPER CREDENTIAL AT /config/crudbooster.php

  1. Create your modules
  2. Create your roles
  3. Add new User

Now you can log out, and try the admin panel by visiting /admin/login

You can always change the admin login at /config/crudbooster.php

Basic Code Knowledge

In this new CRUDBooster, we use single scaffolding for index table and form. For example :
function cbInit() {
    $this->setTable("books");
    $this->setPageTitle("Book Data");
    
    $this->addText("Title");
}

As you can see we add column title it will show at index table, detail, add and edit form.

Types

These bellow are some types that you can use to make form input :

Text

Example

    $this->addText("Foo Bar");
    $this->addText("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional Options available :

| Method | Description | | ------------------ | ---------------- | | ->maxLength(100); | Set max length limit | ->minLength(5); | Set min length limit | | ->strLimit(100);| Set character limit |

Additional options example :

    $this->addText("Foo Bar")->maxLength(100)->minLength(5);

Checkbox

Example

    $this->addCheckbox("Foo Bar");
    $this->addCheckbox("Foo Bar","foo_bar","foo_bar_field");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional options available :

| Method | Description | | --- | --- | | ->options($array); | The options of check box | | ->optionsFromTable($table, $key_field, $display_field, $SQLCondition = null); | The options of check box with table source |

Additional options example :

    $this->addCheckbox("Foo bar")->options(["a"=>"Banana","b"=>"Melon"]);
    $this->addCheckbox("Foo bar")->optionsFromTable("fruits","id","name");

Password

Example

    $this->addPassword("Foo Bar");
    $this->addPassword("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Image

Example

    $this->addImage("Foo Bar");
    $this->addImage("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional options :

| Name | Description | | --- | --- | | ->encrypt(true); | To encrypt the file name set false or true | | ->resize(150, 150); | To resize the image param 1 for width, param 2 for height |

TextArea

Example

    $this->addTextArea("Foo Bar");
    $this->addTextArea("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional options :

| Name | Description | | --- | --- | | ->strLimit($length);|Set column limit characters|

Select

Example

    $this->addSelect("Foo Bar");
    $this->addSelect("Foo Bar","foo_bar","foo_bar_field");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional options available :

| Method | Description | | --- | --- | | ->options($array); | The options of select | | ->optionsFromTable($table, $key_field, $display_field, $SQLCondition = null); | The options of select with table source | | ->foreignKey($parent_select_name); | To enable sub select. The case example is for select a province, city and district| | ->optionsFromQuery($query);| To set the source options by your own DB Query. Should be 2 response field "key" and "label"|

Additional options example :

    $this->addSelect("Foo bar")->options(["a"=>"Banana","b"=>"Melon"]);
    $this->addSelect("Foo bar")->optionsFromTable("fruits","id","name");
    $this->addSelect("Foo Bar")->optionsFromQuery(function() {
        return DB::table("foo")->select("id as key","name as label")->get();
    });

Custom

Example

    $this->addCustom("Foo Bar");
    $this->addCustom("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Date

Example

    $this->addDate("Foo Bar");
    $this->addDate("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional options available :

| Name | Description | | --- | --- | | ->format("Y-m-d"); | The date php format |

Additional options example :

    $this->addDate("foo bar")->format("Y-m-d");

Date & Time

Example

    $this->addDateTime("Foo Bar");
    $this->addDateTime("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional options available :

| Name | Description | | --- | --- | | ->format("Y-m-d H:i:s"); | The date time php format |

Additional options example :

    $this->addDateTime("Foo bar")->format("Y-m-d H:i:s");

Email

Example

    $this->addEmail("Foo Bar");
    $this->addEmail("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Money

Example

    $this->addMoney("Foo Bar");
    $this->addMoney("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional options :

| Name | Description | | --- | --- | | ->prefix("Rp.");| The prefix of money display | | ->precision(2); | The precision of money input | | ->decimalSeparator("."); | The decimal separator of money input | | ->thousandSeparator(","); | The thousand separator of money input |

Additional option example :

    $this->addMoney("Price")->prefix("Rp.")->precision(2);

File Upload

Example

    $this->addFile("Foo Bar");
    $this->addFile("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Hidden Input

Example

    $this->addHidden("Foo Bar");
    $this->addHidden("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Number

Example

    $this->addNumber("Foo Bar");
    $this->addNumber("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Radio Button

Example

    $this->addRadio("Foo Bar");
    $this->addRadio("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional options available :

| Method | Description | | --- | --- | | ->options($array); | The options of radio | | ->optionsFromTable($table, $key_field, $display_field, $SQLCondition = null); | The options of radio with table source | | ->optionsFromQuery($query);| To set the source options by your own DB Query. Should be 2 response field "key" and "label"|

Additional options example :

    $this->addSelect("Foo bar")->options(["a"=>"Banana","b"=>"Melon"]);
    $this->addSelect("Foo bar")->optionsFromTable("fruits","id","name");
    $this->addSelect("Foo Bar")->optionsFromQuery(function() {
        return DB::table("foo")->select("id as key","name as label")->get();
    });

Wysiwyg

Example

    $this->addWysiwyg("Foo Bar");
    $this->addWysiwyg("Foo bar","foo_bar","field_foobar");

Parameters available :

| Name | Description | | ----------------- | ----------------- | | $label | The input label (Required) | | $name | The input name (Optional) | | $field_to_save | The field name if not same with the name (Optional) |

Additional options :

| Name | Description | | --- | --- | | ->strLimit($length);|Set column limit characters|

Additional Basic Options

| Name | Description | | --- | --- | | ->visible($boolean); | To set input visible false or true | | ->defaultValue($value); | To set the default value | | ->inputWidth(12); | To set width of input | | ->columnWidth(100); | To set width of table column | | ->required(true); | To set the mandatory of input | | ->help("Help text"); | To set help text in the bellow of input | | ->placeholder("Enter the text"); | To set the input placeholder | | ->validation("string"); | To set the input validation (laravel validation) |

Example

    $this->addText("Foo Bar")
            ->inputWidth(6)
            ->columnWidth(150)
            ->help("Enter the foo bar")
            ->validation("required|string");

Show column / input to specific page

You can prevent input or column to show only at index table.

    $this->addText("Foo Bar")->showIndex(true)->showEdit(false)->showAdd(false)->showDetail(false);

Buttons Display Control

In this section you can disable / hide buttons in crudbooster

| Name | Description | | --- | --- | | $this->setSearchForm(true); | To show/hide search form | | $this->setButtonLimitPage(true); | To show/hide limit button | | $this->setButtonSave(true); | To show/hide save button | | $this->setButtonAdd(true); | To show/hide add button | | $this->setButtonEdit(true); | To show/hide edit button | | $this->setButtonDetail(true); | To show/hide detail button | | $this->setButtonDelete(true); | To show/hide delete button | | $this->setButtonCancel(true); | To show/hide cancel button at form | | $this->setButtonAddMore(true); | To show/hide add more button at form |

Additional View

In this section you can add additional view or html on before or after CRUDBooster element

| Name | Description | | --- | --- | | $this->setBeforeIndexTable("

html
"); | To set additional html before index table data | | $this->setAfterIndexTable("
html
");
| To set additional html after index table data |
| $this->setBeforeDetailForm(function($row) { return "
html
"; });
| To set additional html before detail form. You can use $row to get current data | | $this->setAfterDetailForm(function($row) { return "
html
"; });
| To set additional html after detail form. You can use $row to get current data |

Additional Index Head Buttons

In this section you can add more buttons on the above of index table

    $this->addIndexActionButton($label, $actionURL, $fontawesomeClass, $color, $attributes);

| Name | Description | | --- | --- | | $label | The button label | | $actionURL | The button action url | | $fontaweseomClass | The button icon use font awesome class | | $color | The button color use ButtonColor::GREEN, ButtonColor::RED, ButtonColor::YELLOW, ButtonColor::LIGHT_BLUE, ButtonColor::DARK_BLUE |

Example :

    $this->addIndexActionButton("Export Data", module()->url('export-data'), 'fa fa-download', ButtonColor::GREEN);

Additional Table Grid Action Buttons

In this section you can add more buttons on the table grid data

    $this->addActionButton($label, $actionURL,  $condition, $fontAwesome, $color, $confirmation);

| Name | Description | | --- | --- | | $label | The button label | | $actionURL | The button action url. You can set as callable with $row parameter | | $condition | The button show condition, this type is callable with $row parameter | | $fontawesome | The button icon, you can use font awesome class | | $color | The button color, you can use ButtonColor::RED(YELLOW,LIGHT_BLUE,GREEN) |

    $this->addActionButton("Download Invoice", function($row) {
        return module()->url("download-invoice/".$row->primary_key);
    },function($row) {
        if($row->status == "PAID") return true;
        else return false;
    }, "fa fa-download");

In the example above you can use magic properties ->primary_key to get the ID of record

Hide Buttons With Condition

Some case you want to hide the detail button, edit button with specific condition.

    $this->hideButtonDetailWhen(function($row) {
        //Write if condition here
    });

The output of this function should be a boolean. True to hide the button, False to show the button.

Example

    $this->hideButtonDeleteWhen(function($row) {
        if($row->status == "PAID") return true;
        else return false;
    });

Method available :

| Name | Description | | --- | --- | | hideButtonDeleteWhen($callback) | To hide delete button | | hideButtonEditWhen($callback) | To hide edit button | | hideButtonDetailWhen($callback) | To hide detail button |

Command Artisan Available

| Name | Description | | --- | --- | | crudbooster:make --module={tableName} | To create a module by table name. Replace {tableName} with the table name | | crudbooster:install | To install the crudbooster for the first time | | crudbooster:seed {--generate}| To backup the cb_* tables data and additional table see at the config/crudbooster.php. This useful if you doing collaboration that need sync the data also. Set option --generate to generating the seeder, or without it to seeder the exisiting seeder file. |

Module Helper Available

| Name | Description | | --- | --- | | module()->getData("key_name") | To get the properties variable at the module controller. Replace key name with the properties var name. | module()->getPageTitle() | To get the module page title | | module()->getTable() | To get the table name of module | | module()->getPageIcon() | To get the page icon of module | | module()->canBrowse() | To check the current user is can browse to the module ? | | module()->canCreate() | To check the current user is can create to the module ? | | module()->canRead() | To check the current user is can read to the module ? | | module()->canUpdate() | To check the current user is can update to the module ? | | module()->canDelete() | To check the current user is can delete to the module ? | | module()->addUrl() | To get the add page url | | module()->editUrl() | To get the edit page url | | module()->detailUrl() | To get the detail page url | | module()->deleteUrl() | To get the delete page url | | module()->url("path/here") | To get the root module url. You can pass the parameter with additional path |

FCM Google Push Notification

To use this feature you have to set the Google FCM Key at config/crudbooster.php

    use crocodicstudio\crudbooster\helpers\FCM;
    
    $fcm = new FCM();
    $title = "Foo Bar Title";
    $message = "The content notification message";
    $data = [];
    $data['foo_data'] = "Hello";
    $data['bar_data'] = "New";
    $fcm->sendToAndroid($reg_id_array, $title, $message, $data);
    
    // Or you can send to ios with this bellow 
    $fcm->sendToIos($reg_id_array, $title, $message,$data);

Star History Chart