All Projects → appoly → smart-schema

appoly / smart-schema

Licence: other
A Laravel package to enable auto generation of forms

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to smart-schema

panichd
Ticketing system for Laravel 5.1 - 8.x. Allows to create new tickets via form only. Includes file attachments, ticket tags, filtering, scheduling and e-mail notifications.
Stars: ✭ 78 (+333.33%)
Mutual labels:  laravel-package, laravel-5-package
Laravel-Unsplash-Wrapper
A Laravel wrapper for Unsplash API's.
Stars: ✭ 21 (+16.67%)
Mutual labels:  laravel-package, laravel-5-package
voyager-page-blocks
A module to provide page blocks for Voyager 📝
Stars: ✭ 80 (+344.44%)
Mutual labels:  laravel-package, laravel-5-package
flash
An easy way for Laravel flash notifications.
Stars: ✭ 14 (-22.22%)
Mutual labels:  laravel-package, laravel-5-package
maintenance-mode
An enhanced maintenance mode for Laravel.
Stars: ✭ 117 (+550%)
Mutual labels:  laravel-package, laravel-5-package
voyager-portfolio
A Portfolio Module for Laravel Voyager 💋
Stars: ✭ 15 (-16.67%)
Mutual labels:  laravel-package, laravel-5-package
sweetalert
Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.
Stars: ✭ 28 (+55.56%)
Mutual labels:  laravel-package, laravel-5-package
Formr
Create and Validate PHP Forms in Seconds.
Stars: ✭ 163 (+805.56%)
Mutual labels:  form-validation, form-builder
correios-consulta
Buscar informações de serviços dos correios diretamente nos sites deles, sem utilizar api de terceiros.
Stars: ✭ 155 (+761.11%)
Mutual labels:  laravel-package, laravel-5-package
react-cool-form
😎 📋 React hooks for forms state and validation, less code more performant.
Stars: ✭ 246 (+1266.67%)
Mutual labels:  form-validation, form-builder
laravel-two-factor-authentication
A two-factor authentication package for Laravel >= 8
Stars: ✭ 37 (+105.56%)
Mutual labels:  laravel-package, laravel-5-package
artisan-shortcuts
🍰 Register shortcuts to execute multiple artisan commands
Stars: ✭ 56 (+211.11%)
Mutual labels:  laravel-package, laravel-5-package
formoj
Form generator package for Laravel
Stars: ✭ 28 (+55.56%)
Mutual labels:  laravel-package, form-builder
Formulary
Declarative iOS TableView Forms in Swift (pre-SwiftUI)
Stars: ✭ 83 (+361.11%)
Mutual labels:  form-validation, form-builder
Elm Form
Dynamic forms handling in Elm
Stars: ✭ 189 (+950%)
Mutual labels:  form-validation, form-builder
laravel-ab
Laravel A/B experiment testing tool
Stars: ✭ 108 (+500%)
Mutual labels:  laravel-package, laravel-5-package
Rsformview
A Cocoapods library designed to easily create forms with multiple data entry fields
Stars: ✭ 84 (+366.67%)
Mutual labels:  form-validation, form-builder
Form For
ReactJS forms made easy
Stars: ✭ 118 (+555.56%)
Mutual labels:  form-validation, form-builder
antd-react-form-builder
Example
Stars: ✭ 74 (+311.11%)
Mutual labels:  form-validation, form-builder
react-declarative
A React form builder which interacts with a JSON endpoint to generate nested 12-column grids with input fields and automatic state management in a declarative style. Endpoint is typed by TypeScript guards (IntelliSense available). This tool is based on material-ui components, so your application will look beautiful on any device...
Stars: ✭ 17 (-5.56%)
Mutual labels:  form-validation, form-builder

Laravel: Smartfields & form helper

Tired of repeating yourself? This package centralises everything to do with fields.

Navigation

Quick Usage

Add to composer.json:

"appoly/smart-schema": "^0.6.3",

Introduction

Instead of having to create a migration, a request, form views and set up fillable fields, we can instead create a smart migration which handles it all.

Example migration:

SmartSchema::create('sites', function ($table) {
    $table->increments("id");

    $table->integer("name");

    $table->text("name")
        ->nullable()
        ->required()
        ->fillable()
        ->max(5)
        ->forms([
            'type' => 'text',
            'label' => 'Site name'
        ]);

    $table->timestamps();
});

Options for fields

Field Types

Standard field types area available.

$table->text("name")
$table->integer("user_id")
$table->float("latitude")

etc...

Virtual Fields

In some cases, we may want fields in a form that don't correspond directy to our database tables.

We can then use:

$table->virtual("slot")->forms(...

Validation Rules

These can be chained to a field creation in your migration.

Example:

$table->text("email")->required()->email();

Available rules:

->unique()
->required()
->email()
->max( val )
->min( val )

Custom validation rules can be added with:

->addRule( rule )

When storing the object in your controller, the validation helper should be called with the object type:

public function store(Request $request) {
    SchemaHelper::validate($request, 'sites');
    
    // Process the request
    // ...
}

Model attributes

fillable()

Casts:

->array()
->datetime()

Model must have the SmartField trait to use fillable() or any of the attribute casts.

class User extends Model
{
    use SmartField;
}

Forms

The form helper will generate (currently Bootstrap 4) forms based on the field data.

In migration, use ->forms([... to show a field in the auto-generated forms:

->forms([
    'type' => 'text',
    'label' => 'Site name'
])

To render a basic form:

{!! \Appoly\SmartSchema\SchemaHelper::form('sites', route('sites.store')) !!}

Multiple choice form fields such as selects and radio buttons will need a set of options.

In the case of the following field:

$table->id("role")
        ->forms([
            'type' => 'select', // or 'type' => 'radio'
            'label' => 'Role'
        ]);

Options can be passed like so:

{!! \Appoly\SmartSchema\SchemaHelper::form('sites', route('sites.store'), [
    'select_options' => [
        'role_id' => ['User', 'Admin']
    ]
]) !!}

Or with keys

{!! \Appoly\SmartSchema\SchemaHelper::form('sites', route('sites.store'), [
    'select_options' => [
        'role_id' => [
            10001 => 'User', 
            20001 => 'Admin'
        ]
    ]
]) !!}

Code Generation

This package includes a console command which will set up a boilerplate controller and view code.

php artisan crud:generate {resource_name_singular}

For example:

php artisan crud:generate client

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].