PHP code example of mydnic / laravel-kustomer

1. Go to this page and download the library: Download mydnic/laravel-kustomer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mydnic / laravel-kustomer example snippets


return [
    // ...
    App\Providers\VoletServiceProvider::class,
];

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Mydnic\Volet\Features\FeedbackMessages;
use Mydnic\Volet\Features\FeatureManager;

class VoletServiceProvider extends ServiceProvider
{
    public function boot(FeatureManager $volet): void
    {
        // Register and configure the Feedback Messages feature
        $this->registerFeedbackMessagesFeature($volet);

        // Example of registering a custom feature
        // $volet->register(new YourCustomFeature());
    }

    private function registerFeedbackMessagesFeature(FeatureManager $volet): void
    {
        $volet->register(
            (new FeedbackMessages)
                // Configure feature display
                ->setLabel('Send us feedback')
                ->setIcon('https://api.iconify.design/lucide:message-square.svg?color=%23888888')

                // Add feedback categories
                ->addCategory(
                    slug: 'general',
                    name: 'General Feedback',
                    icon: 'https://api.iconify.design/lucide:smile.svg?color=%23888888'
                )
                ->addCategory(
                    slug: 'improvement',
                    name: 'Improvement',
                    icon: 'https://api.iconify.design/lucide:lightbulb.svg?color=%23888888'
                )
                ->addCategory(
                    slug: 'bug',
                    name: 'Bug Report',
                    icon: 'https://api.iconify.design/lucide:bug.svg?color=%23888888'
                )
        );
    }
}

namespace App\Volet\Features;

use Mydnic\Volet\Features\BaseFeature;

class CustomFeature extends BaseFeature
{
    public function getId(): string
    {
        return 'custom-chatbot';
    }
    
    public function getLabel(): string
    {
        return 'Talk with our chatbot';
    }
    
    public function getIcon(): string
    {
        return 'https://api.iconify.design/lucide:star.svg?color=%23888888';
    }
    
    public function getComponentName(): ?string
    {
        return 'custom-feature'; // Name of your Web Component
    }
    
    public function getScripts(): ?string
    {
        $scriptUrl = asset('volet-custom-feature.js');
        return "<script src=\"{$scriptUrl}\"></script>";
    }
    
    public function getConfig(): array
    {
        return [
            'routes' => [
                'store' => route('custom-feature.store'),
            ],
            'labels' => [
                'placeholder' => 'Enter your message...',
                'button' => 'Submit',
                'success' => 'Thank you!',
            ],
            // Add any other configuration your component needs
        ];
    }
}

return [
    'feedback-messages' => [
        'table' => 'custom_feedback_table', // Default: 'volet_feedback_messages'
        
        // ...
    ],
];

use Mydnic\Volet\Features\FeedbackMessages;

$volet->register(
    (new FeedbackMessages())
        // Configure feature display
        ->setLabel('Send us feedback')
        ->setIcon('https://api.iconify.design/lucide:message-square.svg?color=%23888888')
        
        // Add feedback categories
        ->addCategory(
            slug: 'bug',
            name: 'Bug Report',
            icon: 'https://api.iconify.design/lucide:bug.svg?color=%23888888'
        )
        ->addCategory(
            slug: 'improvement',
            name: 'Improvement',
            icon: 'https://api.iconify.design/lucide:lightbulb.svg?color=%23888888'
        )
);

(new FeedbackMessages())->disable(); // or ->enable()

namespace App\Observers;

use Mydnic\Volet\Models\FeedbackMessage;
use App\Notifications\NewFeedbackMessageNotification;
use Illuminate\Support\Facades\Notification;

class FeedbackMessageObserver
{
    public function created(FeedbackMessage $feedbackMessage)
    {
        // Send notification to administrators
        Notification::route('mail', '[email protected]')
            ->notify(new NewFeedbackMessageNotification($feedbackMessage));
    }
}

// Register the observer in your AppServiceProvider
public function boot()
{
    FeedbackMessage::observe(FeedbackMessageObserver::class);
}
bash
php artisan vendor:publish --tag="volet-assets" --force
bash
php artisan vendor:publish --tag="volet-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="volet-config"
bash
php artisan vendor:publish --tag="volet-config" --force
php artisan vendor:publish --tag="volet-assets" --force
json
{
    "scripts": {
        "post-package-update": [
            "@php artisan vendor:publish --tag=volet-assets --force"
        ]
    }
}
bash
php artisan vendor:publish --tag="volet-provider"