PHP code example of lyrasoft / contact

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

    

lyrasoft / contact example snippets


$this->lang->loadAllFromVendor(\Lyrasoft\Contact\ContactPackage::class, 'ini');

// Contact
$menu->link('聯絡單')
    ->to($nav->to('contact_list', ['type' => 'main']))
    ->icon('fal fa-phone-volume');

$nav->to('contact_list', ['type' => '{type}']);

    $controller->prepareSave(
        function (PrepareSaveEvent $event) {
            $data = &$event->data;

            $data['type'] = 'foo';
        }
    );

    'rate_limit' => [
        // Default rate limit config
        '_default' => [
            'policy' => 'fixed_window',
            'limit' => 10,
            'interval' => '1day',
        ],
        
        // You can add different rate limit for different type
        'main' => [
            'policy' => 'fixed_window',
            'limit' => 10,
            'interval' => '1day',
        ],
    ],

    public function save(
        AppContext $app,
        ContactService $contactService,
        // ...
    ): mixed {
        // Set your form type
        $type = 'inquiry';
        
        // Check or throw
        $contactService->rateLimitOrThrow($type, $app->getAppRequest()->getClientIP());
        
        // Or throw yourself
        $limit = $contactService->checkRateLimit($type, $app->getAppRequest()->getClientIP());
        
        if (!$limit->isAccepted()) {
            throw new \RuntimeException('Rate limit exceeded', 429);
        }
        

    // ...
shell
php windwalker pkg:install lyrasoft/contact -t lang
shell
php windwalker g controller Admin/FooContact
php windwalker g view Admin/FooContact
php windwalker g form Admin/FooContact/Form/EditForm