1. Go to this page and download the library: Download hanson/laravel-admin-wechat 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/ */
use \Hanson\LaravelAdminWechat\Events\DecryptMobile;
class SaveMobile
{
public function handle(DecryptMobile $event)
{
$event->wechatUser->user()->update([
'phone' => $event->decryptedData['purePhoneNumber'],
'country_code' => $event->decryptedData['countryCode'],
]);
}
}
use \Hanson\LaravelAdminWechat\Events\DecryptUserInfo;
class AfterSaveUserInfo
{
public function handle(DecryptUserInfo $event)
{
// 你的业务
$event->decryptedData['nickname'];
$event->wechatUser;
}
}
use \Hanson\LaravelAdminWechat\Events\OrderPaid;
class AfterSaveUserInfo
{
public function handle(OrderPaid $event)
{
// 你的业务
$wechatOrder = $event->order;
$order = $wechatOrder->order()->update(['status' => 'paid']);
$openId = $wechatOrder->openid;
}
}