PHP code example of dymantic / secretary

1. Go to this page and download the library: Download dymantic/secretary 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/ */

    

dymantic / secretary example snippets




return [
  'sends_email_to' => '[email protected]',
  'slack_endpoint' => 'https://a-totoally-fake-slack-webhook.test/FAKE',
  'slack_recipient' => '#site_messages',
  'notification_channels' => ['mail', 'slack']
];

//ContactFormController.php // or whatever controller you use

public function handleContactForm(\Dymantic\Secretary\Secretary $secretary) {
    //validate your request

    //new up the message
    $message = new \Dymantic\Secretary\ContactMessage([
        'name' => request('name'),
        'email' => request('email'),
        'message_body' => request('message_body')
    ]);

    $secretary->receive($message);

    //you are done now
}

//ContactFormController.php // or whatever controller you use

public function handleContactForm(\Dymantic\Secretary\Secretary $secretary, \Dymantic\Secretary\ContactForm $form) {
    $secretary->receive($form->contactMessage());
    //you are done now
}

//creating a message manually
$message = new \Dymantic\Secretary\ContactMessage([
        'name' => request('name'),
        'email' => request('email'),
        'message_body' => request('message_body'),
        'message_notes' => [
            'phone' => request('phone'),
            'company' => request('company')
        ]
    ]);

//or if using the form request object, just pass the fields you would like to take from the request as an array to the contactMessage method
$form->createMessage(['phone', 'company']);

//get all messages
$secretary->getMessages();

//get archived messages
$secretary->getArchivedMessages();

//get messages from the last week (does NOT 
 php
composer 
 php
//in config/app.php
...
'providers' => [
    //...
    Dymantic\Secretary\SecretaryServiceProvider::class,
    //...
];

...

'aliases' => [
    //...
    'Secretary' => Dymantic\Secretary\Facades\Secretary::class,
];

php artisan vendor:publish --provider="Dymantic\Secretary\SecretaryServiceProvider"

php artisan migrate