Comments (13)
@Dontorpedo can you show me the button code and the event listener for the custom event?
from nova-button.
Buttoncode
Button::make('Paid', 'paid')
->event('App\Events\UnpaidInvoices')
->successText('Done!')
->style('primary-outline')
->visible($this->invoice_paid == false),
listener
<?php
namespace App\Listeners;
use App\Events\UnpaidInvoices;
class MarkAsPaid
{
public function handle(UnpaidInvoices $event)
{
$event->resource->paid_amount = $event->resource->netto_price * 1.2;
$event->resource->invoice_paid = true;
$event->resource->invoice_states = 2;
$event->resource->save();
}
}
and the custom event
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class UnpaidInvoices
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $key;
public $resource;
/**
* Create a new event instance.
*
* @param \App\Order $order
* @return void
*/
public function __construct($resource, $key)
{
$this->resource = $resource;
$this->key = $key;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('channel-name');
}
}
tried also with the default event.. and also with and without keycheck..
from nova-button.
@Dontorpedo and you're on the latest version 1.0.3 ?
Thanks for the info, so far nothing seems wrong with your implementation.
from nova-button.
@dillingham
yes, its the newest version 1.0.3, i tried it also with 1.0.2
from nova-button.
Do you have your routes cached? Might be that you need to run php artisan route:clear
from nova-button.
I’ll re-open when more info is provided :)
from nova-button.
I am getting the same error. I am also looking for the solution.
from nova-button.
@krunaldevs I don’t have enough info to reproduce this and am not experiencing it myself
from nova-button.
My Resource File
Button::make('<i class="fa fa-copy copy text-70 hover:text-primary" title="Copy SMS Promotion"></i>')
->event(new DuplicatePromo($id))
->visible(true)
->onlyOnIndex(),
My Event Class
class DuplicatePromo
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $promo;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($promo_id)
{
$this->promo = SmsPromo::find($promo_id);
}
}
My Listener File
class DuplicatePromoListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param DuplicatePromo $event
* @return void
*/
public function handle(DuplicatePromo $event)
{
\Log::info('Duplicate Promotion', $event->promo);
}
}
After clicking on button it will generate url like this
This is error getting from the Laravel
from nova-button.
@krunaldevs set an attribute to the button
make::(‘icon-html’, ‘some-attribute’)
from nova-button.
Also that’s not how you set events, check the readme.
from nova-button.
@krunaldevs set an attribute to the button
make::(‘icon-html’, ‘some-attribute’)
I think this is the right way to use this Button
Button::make('<i class="fa fa-copy copy text-70 hover:text-primary" title="Copy SMS Promotion"></i>', 'duplicate_smspromo')
->event('App\Events\DuplicatePromo')
->visible(true)
->onlyOnIndex(),
This works for me
Thanks @dillingham
from nova-button.
it could have been a compability issue with another package, don't know the exact steps to reproduce but after updating laravel and nova to newest versions, and removing packages etc.. (i also did something with routes)..
the nova button started working
from nova-button.
Related Issues (20)
- For anyone seeking NOVA4 support
- Capturing User ID in the Event? HOT 1
- Button State - How to succeed or fail? HOT 1
- Button not showing on index with nova-mega-filter in use HOT 1
- Allow to set title attribute to the button to show tooltip HOT 2
- How to make a toogle button with visual change HOT 5
- Display the Button on Create and Update forms HOT 10
- How to customize button text based on record value
- Details when the link has Name-Name
- Error on Safari
- Button not showing on index or detail
- Create link in resource table row HOT 2
- hi, can you plz delete this pull r HOT 1
- Using buttons in relationship fields that reference the parent HOT 1
- Confirm does not show dialogue box HOT 12
- Button on resource with custom indexQuery with grouped results failed HOT 1
- Programmatically disable button state
- Maintainer
- Left Align button needs to be reiterated carefully
- Feature to add column heading
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nova-button.