jorgv / nova-plus-button
A Laravel Nova field.
Installs: 460
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 1
Open Issues: 0
Language:Vue
Requires
- php: >=7.1.0
README
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
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).