/**
  * 注册当前公众号单例.
  *
  * @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());
     });
 }
Beispiel #2
0
 /**
  * 返回服务端.
  *
  * @return Response
  */
 public function server(Request $request, AccountRepository $repository)
 {
     $account = $repository->getByTag($request->t);
     if (!$account) {
         return;
     }
     return $this->server->make($account);
 }
 /**
  * 响应微信请求.
  *
  * @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);
 }
 /**
  * 用户中心首页显示.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //       dump( get_user_avatar(1));
     //
     //        exit;
     // 当前用户的全部公众号
     $accounts = $this->accountRepository->all();
     return user_view('dashboard.index', compact('accounts'));
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #7
0
 /**
  * 获取Account.
  *
  * @param Int $id AccountID
  */
 private function getAccount($accountId)
 {
     $accountRepository = new AccountRepository(new Account());
     return $accountRepository->getById($accountId);
 }
Beispiel #8
0
 protected function buildAccountFilter(Request $request, AccountRepository $account_respository)
 {
     $definition = $account_respository->getSearchFilterDefinition();
     return IndexRequestFilter::createFromRequest($request, $definition);
 }
 /**
  * 删除公众号.
  *
  * @param int $accountId
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy($accountId)
 {
     $this->accountRepository->delete($accountId);
     return success('删除成功!');
 }
 /**
  * 删除公众号.
  *
  * @param ineger $id 公众号iD
  */
 public function getDestroy($id)
 {
     $this->accountRepository->destroy($id);
     return redirect(admin_url('account'))->withMessage('删除成功!');
 }
 /**
  * 删除公众号.
  *
  * @param ineger $id 公众号iD
  */
 public function getDestroy($id)
 {
     $this->accountRepository->destroy($id);
     return responseSuccess('删除成功');
 }