Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages
P

Plus button field

Installation Instructions

composer require jorgv/nova-plus-button

Readme

A simple plus button that runs an ajax request to increment a number field

This package contains a Nova field to add increment button to the index view. This is my first Nova package if you have any suggestion or improvement please let me know, I am certeain there can be better approaches.

This field was made in order to add votes and other numeric values from the index view in a quick way

screenshot of the Plus Button field

Requirements

This field requires an increment method within your controller and a route like this: /api/resour-name/increment/{id}.

Installation

Install this package in your Laravel app via composer:

composer require jorgv/nova-plus-button

Usage

You can use this field in your forms as default number input and in your index view as a button. You can pass the increaseValue as parameter, by default increases by 1.

\\ use Jorgv\PlusButton\PlusButton;

public function fields()
{
    return [
            PlusButton::make('count')->increaseValue(5),
    ];
}

Suggested Method in controller

class YourController extends Controller
{

    public function increment(Request $request, $id)
    {
        if (request()->expectsJson()) {
            $object = Class::find($id);
            $object->count = $request->count;
            $object->save();
            return $object;
            }
    }
}  

Suggested Route

Route::post('class/increase/{id}', 'YourController@increment');

Credits

License

The MIT License (MIT).

Back to Top
Added 7 years ago
Last updated 7 Years Ago
Version 0.6.4
Composer
jorgv/nova-plus-button
GitHub stars 6
Packagist downloads 682

Favorites

4 users favorited

Rating

N/A
(out of 5)
★★★★★
★★★★
★★★
★★
0 ratings

Author

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas