GithubHelp home page GithubHelp logo

Comments (13)

dillingham avatar dillingham commented on July 17, 2024

@Dontorpedo can you show me the button code and the event listener for the custom event?

from nova-button.

Dontorpedo avatar Dontorpedo commented on July 17, 2024

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.

dillingham avatar dillingham commented on July 17, 2024

@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.

Dontorpedo avatar Dontorpedo commented on July 17, 2024

@dillingham
yes, its the newest version 1.0.3, i tried it also with 1.0.2

from nova-button.

ppisecky avatar ppisecky commented on July 17, 2024

@Dontorpedo

Do you have your routes cached? Might be that you need to run php artisan route:clear

from nova-button.

dillingham avatar dillingham commented on July 17, 2024

I’ll re-open when more info is provided :)

from nova-button.

vhkhb avatar vhkhb commented on July 17, 2024

I am getting the same error. I am also looking for the solution.

from nova-button.

dillingham avatar dillingham commented on July 17, 2024

@krunaldevs I don’t have enough info to reproduce this and am not experiencing it myself

from nova-button.

vhkhb avatar vhkhb commented on July 17, 2024

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

image

This is error getting from the Laravel

image

from nova-button.

dillingham avatar dillingham commented on July 17, 2024

@krunaldevs set an attribute to the button

make::(‘icon-html’, ‘some-attribute’)

from nova-button.

dillingham avatar dillingham commented on July 17, 2024

Also that’s not how you set events, check the readme.

from nova-button.

vhkhb avatar vhkhb commented on July 17, 2024

@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.

Dontorpedo avatar Dontorpedo commented on July 17, 2024

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)

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.