dounao4179 2018-09-27 18:48
浏览 44
已采纳

Laravel在Analytics.php中更改view_id的配置值

My config/analytics.php

<?php 

return [

'view_id' => 1111111,


'cache_lifetime_in_minutes' => 60 * 24,


'cache' => [
    'store' => 'file',
  ],
];

What I want to happen is set the view_id => googleApi at my Controller.

public function showSpecificSite($site_id){

$reports = Report::whereHas('site', function($query) use($site_id) {
         $query->where('site_id', $site_id);
})->get(['email_date', 'url', 'recipient', 'report_id', 'site_id']);

$googleApi = DB::table('sites')->where('site_id', $site_id)->value('ga_id');
Config::set('view_id', $googleApi);

$siteName = Site::find($site_id)->site_name;

return view('newsite', compact('site_id', 'siteName', 'reports'));
}

My query

public function showMonthlyReport($site_id, $report_id)
{

$analyticsData = Analytics::performQuery(Period::days(30),
    'ga:',
    [
        'metrics' => 'ga:users,ga:newUsers,ga:sessions,ga:sessionsPerUser,ga:pageviews,ga:pageviewsPerSession,ga:avgSessionDuration,ga:bounceRate',
        'start-date' => '2018-08-01',
        'end-date' => '2018-08-30',
    ]);

}

I tried config:set but it didn't help me at all.

Do you have any idea or thoughts how to fix this?

  • 写回答

2条回答 默认 最新

  • dongyun6229 2018-09-27 18:52
    关注

    You need to use:

    Config::set('analytics.view_id', $googleApi);
    

    At the beginning, you should always put your config name (without .php extension)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?