Code Monkey home page Code Monkey logo

laravel-form-template's Introduction

Laravel Form Template

Latest Version on Packagist Build Status Quality Score Total Downloads

This laravel package allow you to save some form templates to apply them whenever you want. the utility is to avoid filling some inputs again and again, that most of the time have the same values, or maybe to apply some template based on the user choice.

Installation

You can install the package via composer:

composer require soufiene-slimi/laravel-form-template

Then run:

php artisan migrate

Usage

First of all you don't need to import anything since the package provide an alias.

Creating a new template

// creating a new template named 'Template 1' with
// data ['name' => 'foo','email' => '[email protected]']
\Template::make('Template 1', [
    'name' => 'foo',
    'email' => 'foo@administrator.',
]);
// creating a new template named 'Template 1' using a model instance
\Template::makeForModel('Template 1', $user);
// creating a new template named 'Template 1' using a model instance
// and some extra data
\Template::makeForModel('Template 1', $user, ['status_id' => 2]);
// creating a new template named 'Template 1' using a model instance,
//some extra data, and keeping all the model attributes
\Template::makeForModel('Template 1', $user, ['foo' => 'bar'], false);

Note that you can configure the attributes that will be removed from a model during the template creation by publishing the configuration and updating the excluded key.

Applying a template

To apply a template, first you have to use the old() function in your input:

<input type="text" name="name" value="{{ old('name') }}" />

Then find the template and apply it

\Template::first()->apply();

Template is an instance of the Illuminate\Database\Eloquent\Model, this mean that you can use all the Laravel ORM features.

To publish the configuration file run:

php artisan vendor:publish  --provider=SoufieneSlimi\LaravelFormTemplate\LaravelFormTemplateServiceProvider

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.

laravel-form-template's People

Contributors

soufiene-slimi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.