archipatel-sketch / crud
Dynamic CRUD generator for Laravel
Requires
- php: >=8.1
- barryvdh/laravel-dompdf: *
- illuminate/support: ^10.0|^11.0|^12.0
- maatwebsite/excel: *
This package is auto-updated.
Last update: 2026-04-03 10:42:49 UTC
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
TableNotFoundExceptionfor 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,postsandattachmentsfor handling simple crud no need to manually handles attchments. - Relation Table : Define relation key in form field for display relational table data.
Installation
- Require the package via Composer:
composer require archipatel-sketch/crud:dev-main
- 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"
- 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');
});
- 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.