定制 justinmoh/backpack-helper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

justinmoh/backpack-helper

Composer 安装命令:

composer require justinmoh/backpack-helper

包简介

A helper package for Laravel-Backpack CRUD that allows using CRUD components as chained method.

README 文档

README

Latest Version on Packagist Total Downloads

This package intends to provide a friendlier interface while using Backpack CRUD, by makes use of laravel's facade.

According to the way Backpack\Crud works, this package rely the trailing method to perform the magic. Currently these compulsory trailing methods are:

  • public function toField($extraConfigToBeMerged = []): CrudPanel
  • public function toColumn($extraConfigToBeMerged = []): CrudPanel
  • public function toFilter($extraConfigToBeMerged = []): void

All other methods return the current instance $this. In order to perform method chain, refer class source code for api, example:

CrudColumn::init(string $label, ?string $name = null, $priority = null): self
CrudField::init(string $label, ?string $name = null, $width = null): self

There is a 2-steps plan:

  • To include all Backpack CRUD columns, fields, and filters
  • To merge the helper classes into one.

These is no test written, yet.

Installation

Via Composer

$ composer require justinmoh/backpack-helper:~0.2

Usage

use \JustinMoh\BackpackHelper\CrudHelper;
use \JustinMoh\BackpackHelper\Facades\Columns\DatetimeColumn;
use \JustinMoh\BackpackHelper\Facades\Columns\SelectColumn;
use \JustinMoh\BackpackHelper\Facades\Columns\TextColumn;
use \JustinMoh\BackpackHelper\Facades\Fields\RadioField;
use \JustinMoh\BackpackHelper\Facades\Fields\Select2FromArrayField;
use \JustinMoh\BackpackHelper\Facades\Fields\UploadMultipleField;
use \JustinMoh\BackpackHelper\Facades\Filters\Select2MultipleFilter;
use \JustinMoh\BackpackHelper\Facades\Filters\SimpleFilter;

// ...

protected function setupListOperation()
{
    // a datetime column with priority `1`
    DatetimeColumn::init('Date & Time Check In', 'datetime_check_in', 1)
        ->toColumn();

    // you can also separate the method chains.
    DatetimeColumn::label('Date & Time Check Out')->name('datetime_check_out')
        ->toColumn();

    // auto guessing `name` with `label`
    TextColumn::label('Name')->toColumn();

    // backpack's `select` column type
    SelectColumn::init('Category', 'category_id')
        ->entity('category')->attribute('display_name')->model(\App\Category::class)
        ->toColumn();
}

// ...

protected function setupCreateOperation()
{
    // a field with wrapperAttribute col-md-6 (or col-lg-6 ?)
    UploadMultipleField::init('Attach Documents', 'customer_documents', 6)
        ->toField();

    // an inline yes no radio button, disabled
    RadioField::init('Is Vip')->width(3)->inline()
        ->options(CrudHelper::YES_NO_OPTIONS)
        ->disabled()->toField();

    // select 2
    Select2FromArrayField::init('Room Type', 'room_type_id', 4)->required()
        ->options(\App\RoomType::all()->prepend('')->pluck('name','id')->toArray())
        ->toField();
}

// ...

protected function setupListOperation()
{
    SimpleFilter::init('Only New', 'status_new')
        ->query(function() {
            \CRUD::addClause('onlyNew');
        })->toFilter();

    Select2MultipleFilter::label('Select Room Type(s)')
        ->options(
            function () {
                return \App\RoomType::all()->pluck('name', 'id')->toArray();
            }
        )->query(
            function ($value) {
                \CRUD::addClause('whereInRoomTypes', json_decode($values));
            }
        )->toFilter();
}

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.

统计信息

  • 总下载量: 67
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固