archipatel-sketch/crud 问题修复 & 功能扩展

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

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

archipatel-sketch/crud

Composer 安装命令:

composer require archipatel-sketch/crud

包简介

Dynamic CRUD generator for Laravel

README 文档

README

A Laravel package to perform dynamic CRUD operations with configurable form fields and table-based routing. This package is ideal for rapidly building CRUD interfaces for any table in your Laravel application.

Features

  • Dynamic CRUD Operations : Create, read, update, and delete records dynamically.
  • Configurable Form Fields : Define fields, input types, validation rules, and visibility in config/form-fields.php.
  • Dynamic Table Fetching : Handles multiple tables dynamically via URL.
  • Graceful Error Handling : Throws a TableNotFoundException for non-existent tables.
  • DataTables Integration : Displays data in responsive DataTables with configurable visibility.
  • Supports Input Types : text, password, email, image, textarea, date, number, select, radio, checkbox.
  • Tables & Attachments On Seprate Table : when you migrate this package migration automatically create users, posts and attachments for handling simple crud no need to manually handles attchments.
  • Relation Table : Define relation key in form field for display relational table data.

Installation

  1. Require the package via Composer:
composer require archipatel-sketch/crud:dev-main
  1. Configuration

Define your table fields in config/form-fields.php. Each table name should have an array of field definitions and array name same is table name.

Example form-fields.php for users table:

<?php

return [

    'users' => [

        [
            'label' => 'Name',
            'name' => 'name',
            'type' => 'text',
            'rules' => 'required|string|max:255',
            'visible' => true,
        ],

        [
            'label' => 'Email',
            'name' => 'email',
            'type' => 'email',
            'rules' => 'required|email',
            'visible' => true,
        ],

        [
            'label' => 'Image',
            'name' => 'image',
            'type' => 'file',
            'upload_type' => 'single', // 'single' or 'multiple'
            'rules' => 'nullable|image|mimes:jpg,jpeg,png|max:2048',
            'visible' => true,
        ],

        [
            'label' => 'Password',
            'name' => 'password',
            'type' => 'password',
            'rules' => 'required|min:6',
            'visible' => false, // Hidden in DataTables
        ],
        [
            'label' => 'City',
            'name' => 'city',
            'type' => 'select',
            'relation' => [
                'table_name' => 'city',
                'label' => 'city_name',
                'values' => 'id',
            ],
            'default' => 'Surat',
            'rules' => 'nullable|in:relation.values',
            'visible' => true,
            'select_type' => 'single',
            'display_column' => 'relation.label', // display on Data
            'display_on_create' => true,
            'display_on_edit' => true,
        ],

    ],

    // Define additional tables here
    // 'products' => [ ... ],

];

👉 Field Definition Parameters

Parameter Description
label Display name in forms and table headers
name Database column name
type Input type (text, email, password, file, image, textarea, etc.)
placeholder Display on the form input field for enter data specification
default Set default value for input fields
values Set values for radio, checkbox, select with | seprator.
rules Laravel validation rules
visible Show column in DataTables (true / false)
upload_type For file or image fields: 'single' or 'multiple'
select_type For select fields: 'single' or 'multiple'
upload_type For file or image fields: 'single' or 'multiple'
input_style For styling form input fields: full and half default half
display_on_create Display field on create form: true or false default true
display_on_edit Display field on edit form: true or false default false
relation Fetch relatoinal table data. This key use with select input type.with relation key added this three key value.
table_name : set relation join table name. it's required.
label : specify column name which is display in the optoins in select input. it's required.
values : specify column name which is display in the optoins values store on db in select input. it's required.
display_column Use in select input. if set relation key for join table then set it.Mainly use for which column you want to display on data listing time.It define with relation keys relation.label or relation.values

👉 Database Configuration for Query Management

Set the following variables in your .env file to configure the database used for creating and managing queries:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=

👉 Publish Config File

Run the following command to publish the query builder configuration file:

php artisan vendor:publish --tag=config

👉 Run Migrations

Before using the package, run the following command to migrate the required database tables:

php artisan migrate --path=vendor/archipatel-sketch/crud/src/Database/migrations

👉 Set package providers

php artisan vendor:publish --provider="ArchipatelSketch\Crud\Providers\CrudServiceProvider"

👉 Configure seeders

php artisan db:seed --class="CitySeeder"
  1. Routes

Include the package routes in your routes/web.php:

add prefix if you want

Route::group(['prefix' => 'crud'], function () {
    include base_path('vendor/archipatel-sketch/crud/src/Routes/web.php');
});
  1. Usage

Create your database tables matching the names defined in form-fields.php.

Access CRUD operations via URL: http://your-app.test/{table_name}

php artisan serve
http://127.0.0.1:8000/users

if you add the prefix,

http://127.0.0.1:8000/crud/users

👉 CrudController reads the table name from the URL.

👉 Fetches field definitions from config/form-fields.php.

👉 Throws TableNotFoundException if table is not defined.

👉 Renders forms for create/edit and displays data using DataTables.

Example Configuration for posts Table

'posts' => [
    [
        'label' => 'Title',
        'name' => 'title',
        'type' => 'text',
        'rules' => 'required|string|max:255',
        'visible' => true,
    ],
    [
        'label' => 'Content',
        'name' => 'content',
        'type' => 'textarea',
        'rules' => 'required|string',
        'visible' => true,
    ],
    [
        'label' => 'Featured Image',
        'name' => 'featured_image',
        'type' => 'image',
        'upload_type' => 'multiple',
        'rules' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
        'visible' => true,
    ],
    [
        'label' => 'Published At',
        'name' => 'published_at',
        'type' => 'date',
        'rules' => 'nullable|date',
        'visible' => true,
    ],
],

Example Usage

👉 Access users CRUD: http://your-app.test/crud/users

👉 Access posts CRUD: http://your-app.test/crud/posts

👉 If the table does not exist in form-fields.php, a 404 Table Not Found error is returned.

⚠ Notes

Table names in form-fields.php must exactly match database table names. For file/image uploads, ensure storage permissions and proper configuration in config/filesystems.php. CrudServiceProvider must be registered (or auto-discovered) for the package to work. Make sure package routes are included in your application’s web.php.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固