PHP code example of binomeway / nova-contact-tool

1. Go to this page and download the library: Download binomeway/nova-contact-tool 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/ */

    

binomeway / nova-contact-tool example snippets


// NovaServiceProvider.php 
public function tools()
{
    return [
        \OptimistDigital\NovaSettings\NovaSettings\NovaSettings::make(),
        \BinomeWay\NovaContactTool\NovaContactTool\NovaContactTool::make(),
    ];
}

return [
    'default_to' => '',
    'default_subject' => '',
    'save_messages' => true,
    'save_subscribers' => true,
    'priority' => 3,
    'delete_on_unsubscribe' => false,
    'enable_gmail_api' => env('ENABLE_GMAIL_API', false),
];

use BinomeWay\NovaContactTool\Facades\Contact;

$subscriber = Contact::subscribe($email, $name, $phone);

use BinomeWay\NovaContactTool\Facades\Contact;

Contact::unsubscribe($subscriber);

use BinomeWay\NovaContactTool\Facades\Contact;

Contact::send($message, $subscriber);

use BinomeWay\NovaContactTool\Facades\Contact;
use BinomeWay\NovaContactTool\Models\Subscriber;
// Perform validations
// Create a subscriber
$subscriber = new Subscriber();
// or use the subscribe method
$subscriber = Contact::subscribe($email, $name, $phone);

$message = 'Hello!';
$to = '[email protected]'; // Optional

$contact = Contact::send($message, $subscriber, $to);

// Checking if the mail was sent.

if($contact->hasSucceded()){
     flash()->message('success', 'Yay! Email was sent.');
}

if($contact->hasFailed()){
    flash()->message('error', $contact->errorMessage());
}

bash
php artisan vendor:publish --provider="BinomeWay\NovaContactTool\ToolServiceProvider" --tag="nova-contact-tool-migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="BinomeWay\NovaContactTool\ToolServiceProvider" --tag="nova-contact-tool-config"