biswadeep/form-tool 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

biswadeep/form-tool

Composer 安装命令:

composer require biswadeep/form-tool

包简介

A lightweight Laravel form tool to create your admin panel or web app easily!

README 文档

README

StyleCI GitHub

A lightweight Laravel form tool to create your web app or admin panel easily!

Create complex CRUDs easily and save time. Create bug-free and deliver confidently.

I love examples, let's get into it directly:

$model = new DataModel();
$model->db('products', 'productId');

$this->crud = Doc::create($this, $model, function (BluePrint $input) {
    $input->text('productName', 'Product Name')->required();

    $input->select('categoryId', 'Category')->options('categories.categoryId.categoryName')->required();

    $input->number('price', 'Price')->required();

    $input->image('image', 'Image');

    $input->editor('description', 'Description');
});

Let me explain

Let's assume we have a database with a product table named products and with columns productId, productName, categoryId, price, image, description. And we have category table named categories with columns categoryId, categoryName

First, we have created a $model = new DataModel(); and on the 2nd line we have passed the table name and primary id of the product table. This is the simple way we tell the form tool that this is our CRUD table.

Then we create a CRUD by calling Doc::create() and the parameters are:

  1. The Laravel's controller class as $this
  2. Passing the $model we created above
  3. And the last parameter is the Closure which will provide us with a BluePrint as parameter.

Now let's understand our fields inside the Closure. For that let me tell you one thing for the most methods inside closure have 1st parameter as the database column name and 2nd as an optional label of that field. So here are the input fields:
  1. We have created a text field with the column productName and labelled as Product Name and applied the required validation.
  2. Then a dropdown with the column categoryId and labelled as Category instructing form tool to get the options from another table categories and then categoryId & categoryName separated by dots(.) to show as value and text of the <option> tag respectively i.e. <option value="categoryId">categoryName</option>. Finally, we have added the required validation.
  3. Then we have a price field with automatic digit validation as we have specified that it's a number field and then applied the required.
  4. Then we have created an image field which will automatically apply validation for the image file and upload the image under the sub-directory public/storage/. More on the file uploading later.
  5. And at last, we have created an editor by default CKEditor for our description column.

Full Code:

<?php

namespace App\Http\Controllers\Admin;

use Deep\FormTool\Core\Doc;
use Deep\FormTool\Core\BluePrint;
use Deep\FormTool\Core\DataModel;

class ProductsController extends AdminController
{
    // Required for FormTool
    public $title = 'Products';
    public $route = 'products';
    public $singularTitle = 'Product';

    protected $crud = null;

    protected function setup()
    {
        $model = new DataModel();
        $model->db('products', 'productId');

        $this->crud = Doc::create($this, $model, function (BluePrint $input) {
            $input->text('productName', 'Product Name')->required();

            $input->select('categoryId', 'Category')->options('categories.categoryId.categoryName')->required();

            $input->number('price', 'Price')->required();

            $input->image('image', 'Image');

            $input->editor('description', 'Description');
        });

        return $this->crud;
    }
}

This will give us:

  1. Products listing page with Bulk Action (Duplicate, Delete), Search, Pagination, Sorting by Columns, Actions (Edit, Delete)

Screenshot of list page

  1. Product create page with all the fields mentioned above

Screenshot of create page

  1. Product edit page with all the fields mentioned above

Screenshot of edit page

  1. Products trash page: This page will contain deleted items. You can now delete them from trash permanently.

Screenshot of CRUD trash

  1. FormTool Activities: Will store all the activities like what item was created, updated, duplicated, deleted, restored and destroyed permanently.

Screenshot of activites

Screenshot of sctivities updated field

If you have understood this much then you are good to go to start with the package and come back to get help from the below documentation (I prefer this way of learning new things 😉). If you prefer to read the documentation first then read it below.

We have many cool features like this. This is just a start. If you like this package please show it by giving it a star in github.

This package is still under active development.

You can boost start the setup with this skeleton package: form-tool-skeleton

Thanks

biswadeep/form-tool 适用场景与选型建议

biswadeep/form-tool 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 181 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 07 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 biswadeep/form-tool 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 biswadeep/form-tool 我们能提供哪些服务?
定制开发 / 二次开发

基于 biswadeep/form-tool 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-04