<style>.woocommerce-product-gallery{ opacity: 1 !important; }</style>

MODULES

Change Notifications


What does it do?

This module allows you to set email notifications whenever some CRUD entry was created/updated/deleted.

You add Notifications online - as many as you want, and then you download the notifications as part of your generated code.

Notice: Notifications can be generated only online, downloaded panel doesn't have function to add new notifications, you would have to add your custom code then.


How does the result look in QuickAdminPanel code?

We have a special class for notifications:
app/Notifications/QA_EmailNotification.php

class QA_EmailNotification extends Notification
{
    use Queueable;

    public function __construct($data)
    {
        $this->data = $data;
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        return $this->getMessage();
    }

    public function getMessage()
    {
        return (new MailMessage)
            ->subject(config('app.name') . ': entry ' . $this->data["action"] . ' in ' . $this->data['crud_name'])
            ->greeting('Hi,')
            ->line('we would like to inform you that entry has been ' . $this->data["action"] . ' in ' . $this->data['crud_name'])
            ->line('Please log in to see more information.')
            ->action(config('app.name'), url(env('APP_URL')))
            ->line('Thank you')
            ->line(config('app.name') . ' Team')
            ->salutation(" ");
    }

}


Next, we create one Observer file for each CRUD that has notifications.
app/Observers/UserCrudActionObserver.php

class UserCrudActionObserver
{

    public function created(User $model)
    {
        $emails = ["admin@admin.com"];
        $data = [
            "action" => "Created",
            "crud_name" => "Users"
        ];

        $users = \App\User::where("email", $emails)->get();
        Notification::send($users, new QA_EmailNotification($data));

    }

}
And then attach that observer to the model.
app/User.php:
class User extends Authenticatable
{

    public static function boot()
    {
        parent::boot();

        User::observe(new \App\Observers\UserCrudActionObserver);
    }

    // ...

You can easily customize each of the notifications after download by adding more logic in the files above.


How to install/use the module?

First, go to your panel's Modules menu item, find the module in the list and click Install.

Then you will see a new menu item Notifications on the left, where you can add your notifications.

As soon as you're happy with your panel, download the files, and Notifications will work out of the box. Of course, don't forget to configure your email settings.


More information