codemenorg / fakefield

Laravel Fake Field

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Laravel Fake Field

Latest Stable Version Latest Unstable Version License Total Downloads

Hide original field name from end user. It will generate new field name(fake field) every time while you refresh your page.

Installation

You can install the package via composer:

composer require codemenorg/fakefield

For Laravel 5.8 use composer require codemenorg/fakefield:1.0.0

Usage

After installing the package, run the following command to generate fakefield.php config file. Here you have to define fake field prefix and Eloquent Model path.

php artisan vendor:publish --tag=fake-field-config 

Add FakeFieldMiddleware to app\Http\Kernel.php web middleware group section.

protected $middlewareGroups = [
        'web' => [
            ...
            \Codemen\FakeField\FakeFieldMiddleware::class,
        ],
        ...
    ];

Inside your model you have to define which fields you want to change.

protected $fakeFields = ['first_name', 'last_name', 'email'];

Now you are ready to use fake field inside your form.

<form action="">
    @csrf
    @fakeKey
    <!-- <input type="hidden" name="_fake_key" value="eyJpdiI6Ij...wOG9BPT0ifQ"> -->
    
    <input type="text" name="{{ fake_field('first_name')}}">
    <!-- <input type="text" name="fake_345"> -->
    <input type="text" name="{{ fake_field('last_name')}}">
    <!-- <input type="text" name="fake_53"> -->
    <input type="text" name="{{ fake_field('email')}}">
    <!-- <input type="text" name="fake_24"> -->
    
    <button type="submit">Submit</button>
    
</form>

Here @fakeKey blade directive will generate a fake key without fake field will not working properly. You can also use fake_key() helper function to generate fake key.

fake_field() helper function will generate fake field.

If the field is not defined in Model then the function will return original field name.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

To contribute you can create a pull request. But please check all functionality are working before creating pull request. We will publish your name on contribution list.

Security

If you discover any security related issues, please email codemenorg@gmail.com instead of using the issue tracker.

Credits

License

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

About

Laravel Fake Field

License:MIT License


Languages

Language:PHP 100.0%