Install from composer
composer require lyrasoft/contact
Then copy files to project
php windwalker pkg:install lyrasoft/contact -t routes -t lang -t migrations -t seeders
Seeders
- Add
contact-seeder.php
toresources/seeders/main.php
Languages
If you don't want to copy language files, remove -t lang
from install command.
Then add this line to admin & front middleware:
$this->lang->loadAllFromVendor(\Lyrasoft\Contact\ContactPackage::class, 'ini');
Edit resources/menu/admin/sidemenu.menu.php
// Contact
$menu->link('聯絡單')
->to($nav->to('contact_list', ['type' => 'main']))
->icon('fal fa-phone-volume');
Use Route to separate types:
/admin/contact/list/{type}
Use type
param in Navigator.
$nav->to('contact_list', ['type' => '{type}']);
One MVC per type. If you want another contact form with type: foo
, just generate a FooContact
MVC
php windwalker g controller Admin/FooContact
php windwalker g view Admin/FooContact
php windwalker g form Admin/FooContact/Form/EditForm
And remember set type when saving in controller:
$controller->prepareSave(
function (PrepareSaveEvent $event) {
$data = &$event->getData();
$data['type'] = 'foo';
}
);