Пример #1
0
 /**
  * 注册当前公众号单例.
  *
  * @return Account
  */
 protected function registerCurrentAccount()
 {
     $this->app->singleton('viease.current_account', function () {
         $repositorie = new AccountRepository(new AccountModel());
         return $repositorie->getById(app('viease.account_service')->chosedId());
     });
 }
Пример #2
0
 /**
  * 返回服务端.
  *
  * @return Response
  */
 public function server(Request $request, AccountRepository $repository)
 {
     $account = $repository->getByTag($request->t);
     if (!$account) {
         return;
     }
     return $this->server->make($account);
 }
Пример #3
0
 /**
  * 响应微信请求.
  *
  * @param Request           $request
  * @param AccountRepository $accountRepository
  *
  * @return mixed|void
  */
 public function serve(Request $request, AccountRepository $accountRepository)
 {
     // 根据token查询公众号信息
     $account = $accountRepository->getByToken($request->route('token'));
     if (empty($account)) {
         return;
     }
     return $this->wechatService->response($account);
 }
Пример #4
0
 /**
  * 用户中心首页显示.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //       dump( get_user_avatar(1));
     //
     //        exit;
     // 当前用户的全部公众号
     $accounts = $this->accountRepository->all();
     return user_view('dashboard.index', compact('accounts'));
 }
Пример #5
0
 /**
  * 是否已经选择了公众号并且公众号属于当前登录用户.
  *
  * @return bool
  */
 private function checkAccount()
 {
     // 当前选中的公众号ID
     $accountId = get_chosed_account();
     if (empty($accountId)) {
         return false;
     }
     //选中的公众号所属用户ID
     $accountUserId = $this->accountRepository->getAccountUserId($accountId);
     if ($accountUserId != auth()->user()->id) {
         return false;
     }
     return true;
 }
Пример #6
0
 /**
  * 获取SDK相关配置数据
  * 未传参数时默认获取当前选中的公众号对应的配置.
  *
  * @param null $accountId
  *
  * @return array
  */
 public function getWechatOptions($accountId = null)
 {
     $accountId = $accountId ?: $this->chosedId();
     $accountData = $this->accountRepository->skipCriteria()->find($accountId);
     $options = ['debug' => true, 'app_id' => $accountData->app_id, 'secret' => $accountData->app_secret, 'token' => $accountData->token, 'log' => ['level' => \Monolog\Logger::DEBUG, 'file' => storage_path('logs/easywechat.log')], 'oauth' => ['scopes' => ['snsapi_userinfo'], 'callback' => '/examples/oauth_callback.php'], 'payment' => ['merchant_id' => $accountData->merchant_id, 'key' => $accountData->key, 'cert_path' => $accountData->cert_path, 'key_path' => $accountData->key_path]];
     return $options;
 }
Пример #7
0
 /**
  * 获取Account.
  *
  * @param Int $id AccountID
  */
 private function getAccount($accountId)
 {
     $accountRepository = new AccountRepository(new Account());
     return $accountRepository->getById($accountId);
 }
Пример #8
0
 protected function buildAccountFilter(Request $request, AccountRepository $account_respository)
 {
     $definition = $account_respository->getSearchFilterDefinition();
     return IndexRequestFilter::createFromRequest($request, $definition);
 }
Пример #9
0
 /**
  * 删除公众号.
  *
  * @param int $accountId
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy($accountId)
 {
     $this->accountRepository->delete($accountId);
     return success('删除成功!');
 }
Пример #10
0
 /**
  * 删除公众号.
  *
  * @param ineger $id 公众号iD
  */
 public function getDestroy($id)
 {
     $this->accountRepository->destroy($id);
     return redirect(admin_url('account'))->withMessage('删除成功!');
 }
Пример #11
0
 /**
  * 删除公众号.
  *
  * @param ineger $id 公众号iD
  */
 public function getDestroy($id)
 {
     $this->accountRepository->destroy($id);
     return responseSuccess('删除成功');
 }