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/ */
//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