├── .gitignore
├── CONTRIBUTING.md
├── README.md
├── Vagrantfile
├── app
├── commands
│ └── .gitkeep
├── config
│ ├── analytics.php
│ ├── app.php
│ ├── auth.php
│ ├── cache.php
│ ├── compile.php
│ ├── database.php
│ ├── local
│ │ ├── app.php
│ │ └── database.php
│ ├── mail.php
│ ├── packages
│ │ └── .gitkeep
│ ├── queue.php
│ ├── remote.php
│ ├── services.php
│ ├── session.php
│ ├── testing
│ │ ├── cache.php
│ │ └── session.php
│ ├── view.php
│ └── workbench.php
├── controllers
│ ├── .gitkeep
│ ├── BaseController.php
│ └── HomeController.php
├── database
│ ├── migrations
│ │ └── .gitkeep
│ ├── production.sqlite
│ └── seeds
│ │ ├── .gitkeep
│ │ └── DatabaseSeeder.php
├── filters.php
├── lang
│ └── en
│ │ ├── pagination.php
│ │ ├── reminders.php
│ │ └── validation.php
├── models
│ └── User.php
├── routes.php
├── src
│ ├── GA_Service.php
│ └── GA_Utils.php
├── start
│ ├── artisan.php
│ ├── global.php
│ └── local.php
├── storage
│ ├── .gitignore
│ ├── cache
│ │ └── .gitignore
│ ├── logs
│ │ └── .gitignore
│ ├── meta
│ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
├── tests
│ ├── ExampleTest.php
│ └── TestCase.php
└── views
│ ├── emails
│ └── auth
│ │ └── reminder.blade.php
│ ├── hello.php
│ ├── home.blade.php
│ ├── login.blade.php
│ └── report.blade.php
├── artisan
├── bootstrap
├── autoload.php
├── paths.php
└── start.php
├── composer.json
├── phpunit.xml
├── public
├── .htaccess
├── css
│ └── daterangepicker-bs2.css
├── favicon.ico
├── index.php
├── js
│ └── daterangepicker.js
├── packages
│ └── .gitkeep
└── robots.txt
├── readme.md
└── server.php
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | composer.phar
3 | composer.lock
4 | .env.*.php
5 | .env.php
6 | .DS_Store
7 | Thumbs.db
8 | vim
9 | .project
10 | .buildpath
11 | .idea/
12 | .vagrant/
13 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contribution Guidelines
2 |
3 | Please submit all issues and pull requests to the [laravel/framework](http://github.com/laravel/framework) repository!
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | laravel_google_analytics
2 | ========================
3 |
4 | Small demo for the "Using Google Analytics API"
5 |
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | # -*- mode: ruby -*-
2 | # vi: set ft=ruby :
3 |
4 | # Config Github Settings
5 | github_username = "fideloper"
6 | github_repo = "Vaprobash"
7 | github_branch = "1.3.1"
8 | github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"
9 |
10 | # Server Configuration
11 |
12 | hostname = "vaprobash.dev"
13 |
14 | # Set a local private network IP address.
15 | # See http://en.wikipedia.org/wiki/Private_network for explanation
16 | # You can use the following IP ranges:
17 | # 10.0.0.1 - 10.255.255.254
18 | # 172.16.0.1 - 172.31.255.254
19 | # 192.168.0.1 - 192.168.255.254
20 | server_ip = "192.168.22.10"
21 | server_cpus = "1" # Cores
22 | server_memory = "384" # MB
23 | server_swap = "768" # Options: false | int (MB) - Guideline: Between one or two times the server_memory
24 |
25 | # UTC for Universal Coordinated Time
26 | # EST for Eastern Standard Time
27 | # US/Central for American Central
28 | # US/Eastern for American Eastern
29 | server_timezone = "UTC"
30 |
31 | # Database Configuration
32 | mysql_root_password = "root" # We'll assume user "root"
33 | mysql_version = "5.5" # Options: 5.5 | 5.6
34 | mysql_enable_remote = "false" # remote access enabled when true
35 | pgsql_root_password = "root" # We'll assume user "root"
36 | mongo_enable_remote = "false" # remote access enabled when true
37 |
38 | # Languages and Packages
39 | php_timezone = "UTC" # http://php.net/manual/en/timezones.php
40 | php_version = "5.6" # Options: 5.5 | 5.6
41 | ruby_version = "latest" # Choose what ruby version should be installed (will also be the default version)
42 | ruby_gems = [ # List any Ruby Gems that you want to install
43 | #"jekyll",
44 | #"sass",
45 | #"compass",
46 | ]
47 |
48 | # To install HHVM instead of PHP, set this to "true"
49 | hhvm = "false"
50 |
51 | # PHP Options
52 | composer_packages = [ # List any global Composer packages that you want to install
53 | #"phpunit/phpunit:4.0.*",
54 | #"codeception/codeception=*",
55 | #"phpspec/phpspec:2.0.*@dev",
56 | #"squizlabs/php_codesniffer:1.5.*",
57 | ]
58 |
59 | # Default web server document root
60 | # Symfony's public directory is assumed "web"
61 | # Laravel's public directory is assumed "public"
62 | public_folder = "/vagrant/public"
63 |
64 | laravel_root_folder = "/vagrant/laravel" # Where to install Laravel. Will `composer install` if a composer.json file exists
65 | laravel_version = "latest-stable" # If you need a specific version of Laravel, set it here
66 | symfony_root_folder = "/vagrant/symfony" # Where to install Symfony.
67 |
68 | nodejs_version = "latest" # By default "latest" will equal the latest stable version
69 | nodejs_packages = [ # List any global NodeJS packages that you want to install
70 | #"grunt-cli",
71 | #"gulp",
72 | #"bower",
73 | #"yo",
74 | ]
75 |
76 | # RabbitMQ settings
77 | rabbitmq_user = "user"
78 | rabbitmq_password = "password"
79 |
80 | sphinxsearch_version = "rel22" # rel20, rel21, rel22, beta, daily, stable
81 |
82 |
83 | Vagrant.configure("2") do |config|
84 |
85 | # Set server to Ubuntu 14.04
86 | config.vm.box = "ubuntu/trusty64"
87 |
88 | config.vm.define "Vaprobash" do |vapro|
89 | end
90 |
91 | if Vagrant.has_plugin?("vagrant-hostmanager")
92 | config.hostmanager.enabled = true
93 | config.hostmanager.manage_host = true
94 | config.hostmanager.ignore_private_ip = false
95 | config.hostmanager.include_offline = false
96 | end
97 |
98 | # Create a hostname, don't forget to put it to the `hosts` file
99 | # This will point to the server's default virtual host
100 | # TO DO: Make this work with virtualhost along-side xip.io URL
101 | config.vm.hostname = hostname
102 |
103 | # Create a static IP
104 | config.vm.network :private_network, ip: server_ip
105 | config.vm.network :forwarded_port, guest: 80, host: 8000
106 |
107 | # Use NFS for the shared folder
108 | config.vm.synced_folder ".", "/vagrant",
109 | id: "core",
110 | :nfs => true,
111 | :mount_options => ['nolock,vers=3,udp,noatime']
112 |
113 | # If using VirtualBox
114 | config.vm.provider :virtualbox do |vb|
115 |
116 | vb.name = "Vaprobash_google_analytics"
117 |
118 | # Set server cpus
119 | vb.customize ["modifyvm", :id, "--cpus", server_cpus]
120 |
121 | # Set server memory
122 | vb.customize ["modifyvm", :id, "--memory", server_memory]
123 |
124 | # Set the timesync threshold to 10 seconds, instead of the default 20 minutes.
125 | # If the clock gets more than 15 minutes out of sync (due to your laptop going
126 | # to sleep for instance, then some 3rd party services will reject requests.
127 | vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]
128 |
129 | # Prevent VMs running on Ubuntu to lose internet connection
130 | # vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
131 | # vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
132 |
133 | end
134 |
135 | # If using VMWare Fusion
136 | config.vm.provider "vmware_fusion" do |vb, override|
137 | override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box"
138 |
139 | # Set server memory
140 | vb.vmx["memsize"] = server_memory
141 |
142 | end
143 |
144 | # If using Vagrant-Cachier
145 | # http://fgrehm.viewdocs.io/vagrant-cachier
146 | if Vagrant.has_plugin?("vagrant-cachier")
147 | # Configure cached packages to be shared between instances of the same base box.
148 | # Usage docs: http://fgrehm.viewdocs.io/vagrant-cachier/usage
149 | config.cache.scope = :box
150 |
151 | config.cache.synced_folder_opts = {
152 | type: :nfs,
153 | mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
154 | }
155 | end
156 |
157 | # Adding vagrant-digitalocean provider - https://github.com/smdahlen/vagrant-digitalocean
158 | # Needs to ensure that the vagrant plugin is installed
159 | config.vm.provider :digital_ocean do |provider, override|
160 | override.ssh.private_key_path = '~/.ssh/id_rsa'
161 | override.vm.box = 'digital_ocean'
162 | override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
163 |
164 | provider.token = 'YOUR TOKEN'
165 | provider.image = 'Ubuntu 14.04 x64'
166 | provider.region = 'nyc2'
167 | provider.size = '512mb'
168 | end
169 |
170 | ####
171 | # Base Items
172 | ##########
173 |
174 | # Provision Base Packages
175 | config.vm.provision "shell", path: "#{github_url}/scripts/base.sh", args: [github_url, server_swap, server_timezone]
176 |
177 | # optimize base box
178 | config.vm.provision "shell", path: "#{github_url}/scripts/base_box_optimizations.sh", privileged: true
179 |
180 | # Provision PHP
181 | config.vm.provision "shell", path: "#{github_url}/scripts/php.sh", args: [php_timezone, hhvm, php_version]
182 |
183 | # Enable MSSQL for PHP
184 | # config.vm.provision "shell", path: "#{github_url}/scripts/mssql.sh"
185 |
186 | # Provision Vim
187 | config.vm.provision "shell", path: "#{github_url}/scripts/vim.sh", args: github_url
188 |
189 | # Provision Docker
190 | # config.vm.provision "shell", path: "#{github_url}/scripts/docker.sh"
191 |
192 |
193 | ####
194 | # Web Servers
195 | ##########
196 |
197 | # Provision Apache Base
198 | config.vm.provision "shell", path: "#{github_url}/scripts/apache.sh", args: [server_ip, public_folder, hostname, github_url]
199 |
200 | # Provision Nginx Base
201 | # config.vm.provision "shell", path: "#{github_url}/scripts/nginx.sh", args: [server_ip, public_folder, hostname, github_url]
202 |
203 |
204 | ####
205 | # Databases
206 | ##########
207 |
208 | # Provision MySQL
209 | config.vm.provision "shell", path: "#{github_url}/scripts/mysql.sh", args: [mysql_root_password, mysql_version, mysql_enable_remote]
210 |
211 | # Provision PostgreSQL
212 | # config.vm.provision "shell", path: "#{github_url}/scripts/pgsql.sh", args: pgsql_root_password
213 |
214 | # Provision SQLite
215 | # config.vm.provision "shell", path: "#{github_url}/scripts/sqlite.sh"
216 |
217 | # Provision RethinkDB
218 | # config.vm.provision "shell", path: "#{github_url}/scripts/rethinkdb.sh", args: pgsql_root_password
219 |
220 | # Provision Couchbase
221 | # config.vm.provision "shell", path: "#{github_url}/scripts/couchbase.sh"
222 |
223 | # Provision CouchDB
224 | # config.vm.provision "shell", path: "#{github_url}/scripts/couchdb.sh"
225 |
226 | # Provision MongoDB
227 | # config.vm.provision "shell", path: "#{github_url}/scripts/mongodb.sh", args: mongo_enable_remote
228 |
229 | # Provision MariaDB
230 | # config.vm.provision "shell", path: "#{github_url}/scripts/mariadb.sh", args: [mysql_root_password, mysql_enable_remote]
231 |
232 | ####
233 | # Search Servers
234 | ##########
235 |
236 | # Install Elasticsearch
237 | # config.vm.provision "shell", path: "#{github_url}/scripts/elasticsearch.sh"
238 |
239 | # Install SphinxSearch
240 | # config.vm.provision "shell", path: "#{github_url}/scripts/sphinxsearch.sh", args: [sphinxsearch_version]
241 |
242 | ####
243 | # Search Server Administration (web-based)
244 | ##########
245 |
246 | # Install ElasticHQ
247 | # Admin for: Elasticsearch
248 | # Works on: Apache2, Nginx
249 | # config.vm.provision "shell", path: "#{github_url}/scripts/elastichq.sh"
250 |
251 |
252 | ####
253 | # In-Memory Stores
254 | ##########
255 |
256 | # Install Memcached
257 | # config.vm.provision "shell", path: "#{github_url}/scripts/memcached.sh"
258 |
259 | # Provision Redis (without journaling and persistence)
260 | # config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh"
261 |
262 | # Provision Redis (with journaling and persistence)
263 | # config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh", args: "persistent"
264 | # NOTE: It is safe to run this to add persistence even if originally provisioned without persistence
265 |
266 |
267 | ####
268 | # Utility (queue)
269 | ##########
270 |
271 | # Install Beanstalkd
272 | # config.vm.provision "shell", path: "#{github_url}/scripts/beanstalkd.sh"
273 |
274 | # Install Heroku Toolbelt
275 | # config.vm.provision "shell", path: "https://toolbelt.heroku.com/install-ubuntu.sh"
276 |
277 | # Install Supervisord
278 | # config.vm.provision "shell", path: "#{github_url}/scripts/supervisord.sh"
279 |
280 | # Install ØMQ
281 | # config.vm.provision "shell", path: "#{github_url}/scripts/zeromq.sh"
282 |
283 | # Install RabbitMQ
284 | # config.vm.provision "shell", path: "#{github_url}/scripts/rabbitmq.sh", args: [rabbitmq_user, rabbitmq_password]
285 |
286 | ####
287 | # Additional Languages
288 | ##########
289 |
290 | # Install Nodejs
291 | # config.vm.provision "shell", path: "#{github_url}/scripts/nodejs.sh", privileged: false, args: nodejs_packages.unshift(nodejs_version, github_url)
292 |
293 | # Install Ruby Version Manager (RVM)
294 | # config.vm.provision "shell", path: "#{github_url}/scripts/rvm.sh", privileged: false, args: ruby_gems.unshift(ruby_version)
295 |
296 | ####
297 | # Frameworks and Tooling
298 | ##########
299 |
300 | # Provision Composer
301 | config.vm.provision "shell", path: "#{github_url}/scripts/composer.sh", privileged: false, args: composer_packages.join(" ")
302 |
303 | # Provision Laravel
304 | # config.vm.provision "shell", path: "#{github_url}/scripts/laravel.sh", privileged: false, args: [server_ip, laravel_root_folder, public_folder, laravel_version]
305 |
306 | # Provision Symfony
307 | # config.vm.provision "shell", path: "#{github_url}/scripts/symfony.sh", privileged: false, args: [server_ip, symfony_root_folder, public_folder]
308 |
309 | # Install Screen
310 | # config.vm.provision "shell", path: "#{github_url}/scripts/screen.sh"
311 |
312 | # Install Mailcatcher
313 | # config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh"
314 |
315 | # Install git-ftp
316 | # config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false
317 |
318 | # Install Ansible
319 | # config.vm.provision "shell", path: "#{github_url}/scripts/ansible.sh"
320 |
321 | ####
322 | # Local Scripts
323 | # Any local scripts you may want to run post-provisioning.
324 | # Add these to the same directory as the Vagrantfile.
325 | ##########
326 | # config.vm.provision "shell", path: "./local-script.sh"
327 |
328 | end
329 |
--------------------------------------------------------------------------------
/app/commands/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sitepoint-editors/laravel_google_analytics/e1ab3e7aa78d12f7525925b736304c18a84fff84/app/commands/.gitkeep
--------------------------------------------------------------------------------
/app/config/analytics.php:
--------------------------------------------------------------------------------
1 | 'Google Analytics Demo', //Can be anything
5 | 'client_id' => '746489652683-nm0f1ch25uj8b5jrd5t84om8neuh7ikl.apps.googleusercontent.com',//can be found on the credentials page
6 | 'client_secret' => 'LIXspPYOyS3OO7Ma_An7m_LD',//on the credentials page
7 | 'api_key' => 'AIzaSyCkPNlbrfpAlOR57o_fZdhLmDI3yGJFJ38'//can be found at the bottom of your credentials page
8 | ];
9 |
--------------------------------------------------------------------------------
/app/config/app.php:
--------------------------------------------------------------------------------
1 | true,
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Application URL
21 | |--------------------------------------------------------------------------
22 | |
23 | | This URL is used by the console to properly generate URLs when using
24 | | the Artisan command line tool. You should set this to the root of
25 | | your application so that it is used when running Artisan tasks.
26 | |
27 | */
28 |
29 | 'url' => 'http://localhost',
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Application Timezone
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may specify the default timezone for your application, which
37 | | will be used by the PHP date and date-time functions. We have gone
38 | | ahead and set this to a sensible default for you out of the box.
39 | |
40 | */
41 |
42 | 'timezone' => 'UTC',
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Application Locale Configuration
47 | |--------------------------------------------------------------------------
48 | |
49 | | The application locale determines the default locale that will be used
50 | | by the translation service provider. You are free to set this value
51 | | to any of the locales which will be supported by the application.
52 | |
53 | */
54 |
55 | 'locale' => 'en',
56 |
57 | /*
58 | |--------------------------------------------------------------------------
59 | | Application Fallback Locale
60 | |--------------------------------------------------------------------------
61 | |
62 | | The fallback locale determines the locale to use when the current one
63 | | is not available. You may change the value to correspond to any of
64 | | the language folders that are provided through your application.
65 | |
66 | */
67 |
68 | 'fallback_locale' => 'en',
69 |
70 | /*
71 | |--------------------------------------------------------------------------
72 | | Encryption Key
73 | |--------------------------------------------------------------------------
74 | |
75 | | This key is used by the Illuminate encrypter service and should be set
76 | | to a random, 32 character string, otherwise these encrypted strings
77 | | will not be safe. Please do this before deploying an application!
78 | |
79 | */
80 |
81 | 'key' => 'J3rNY90SJ2B6Pd25zsHrBGm8MRfzhToW',
82 |
83 | 'cipher' => MCRYPT_RIJNDAEL_128,
84 |
85 | /*
86 | |--------------------------------------------------------------------------
87 | | Autoloaded Service Providers
88 | |--------------------------------------------------------------------------
89 | |
90 | | The service providers listed here will be automatically loaded on the
91 | | request to your application. Feel free to add your own services to
92 | | this array to grant expanded functionality to your applications.
93 | |
94 | */
95 |
96 | 'providers' => array(
97 |
98 | 'Illuminate\Foundation\Providers\ArtisanServiceProvider',
99 | 'Illuminate\Auth\AuthServiceProvider',
100 | 'Illuminate\Cache\CacheServiceProvider',
101 | 'Illuminate\Session\CommandsServiceProvider',
102 | 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
103 | 'Illuminate\Routing\ControllerServiceProvider',
104 | 'Illuminate\Cookie\CookieServiceProvider',
105 | 'Illuminate\Database\DatabaseServiceProvider',
106 | 'Illuminate\Encryption\EncryptionServiceProvider',
107 | 'Illuminate\Filesystem\FilesystemServiceProvider',
108 | 'Illuminate\Hashing\HashServiceProvider',
109 | 'Illuminate\Html\HtmlServiceProvider',
110 | 'Illuminate\Log\LogServiceProvider',
111 | 'Illuminate\Mail\MailServiceProvider',
112 | 'Illuminate\Database\MigrationServiceProvider',
113 | 'Illuminate\Pagination\PaginationServiceProvider',
114 | 'Illuminate\Queue\QueueServiceProvider',
115 | 'Illuminate\Redis\RedisServiceProvider',
116 | 'Illuminate\Remote\RemoteServiceProvider',
117 | 'Illuminate\Auth\Reminders\ReminderServiceProvider',
118 | 'Illuminate\Database\SeedServiceProvider',
119 | 'Illuminate\Session\SessionServiceProvider',
120 | 'Illuminate\Translation\TranslationServiceProvider',
121 | 'Illuminate\Validation\ValidationServiceProvider',
122 | 'Illuminate\View\ViewServiceProvider',
123 | 'Illuminate\Workbench\WorkbenchServiceProvider',
124 |
125 | ),
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Service Provider Manifest
130 | |--------------------------------------------------------------------------
131 | |
132 | | The service provider manifest is used by Laravel to lazy load service
133 | | providers which are not needed for each request, as well to keep a
134 | | list of all of the services. Here, you may set its storage spot.
135 | |
136 | */
137 |
138 | 'manifest' => storage_path().'/meta',
139 |
140 | /*
141 | |--------------------------------------------------------------------------
142 | | Class Aliases
143 | |--------------------------------------------------------------------------
144 | |
145 | | This array of class aliases will be registered when this application
146 | | is started. However, feel free to register as many as you wish as
147 | | the aliases are "lazy" loaded so they don't hinder performance.
148 | |
149 | */
150 |
151 | 'aliases' => array(
152 |
153 | 'App' => 'Illuminate\Support\Facades\App',
154 | 'Artisan' => 'Illuminate\Support\Facades\Artisan',
155 | 'Auth' => 'Illuminate\Support\Facades\Auth',
156 | 'Blade' => 'Illuminate\Support\Facades\Blade',
157 | 'Cache' => 'Illuminate\Support\Facades\Cache',
158 | 'ClassLoader' => 'Illuminate\Support\ClassLoader',
159 | 'Config' => 'Illuminate\Support\Facades\Config',
160 | 'Controller' => 'Illuminate\Routing\Controller',
161 | 'Cookie' => 'Illuminate\Support\Facades\Cookie',
162 | 'Crypt' => 'Illuminate\Support\Facades\Crypt',
163 | 'DB' => 'Illuminate\Support\Facades\DB',
164 | 'Eloquent' => 'Illuminate\Database\Eloquent\Model',
165 | 'Event' => 'Illuminate\Support\Facades\Event',
166 | 'File' => 'Illuminate\Support\Facades\File',
167 | 'Form' => 'Illuminate\Support\Facades\Form',
168 | 'Hash' => 'Illuminate\Support\Facades\Hash',
169 | 'HTML' => 'Illuminate\Support\Facades\HTML',
170 | 'Input' => 'Illuminate\Support\Facades\Input',
171 | 'Lang' => 'Illuminate\Support\Facades\Lang',
172 | 'Log' => 'Illuminate\Support\Facades\Log',
173 | 'Mail' => 'Illuminate\Support\Facades\Mail',
174 | 'Paginator' => 'Illuminate\Support\Facades\Paginator',
175 | 'Password' => 'Illuminate\Support\Facades\Password',
176 | 'Queue' => 'Illuminate\Support\Facades\Queue',
177 | 'Redirect' => 'Illuminate\Support\Facades\Redirect',
178 | 'Redis' => 'Illuminate\Support\Facades\Redis',
179 | 'Request' => 'Illuminate\Support\Facades\Request',
180 | 'Response' => 'Illuminate\Support\Facades\Response',
181 | 'Route' => 'Illuminate\Support\Facades\Route',
182 | 'Schema' => 'Illuminate\Support\Facades\Schema',
183 | 'Seeder' => 'Illuminate\Database\Seeder',
184 | 'Session' => 'Illuminate\Support\Facades\Session',
185 | 'SoftDeletingTrait' => 'Illuminate\Database\Eloquent\SoftDeletingTrait',
186 | 'SSH' => 'Illuminate\Support\Facades\SSH',
187 | 'Str' => 'Illuminate\Support\Str',
188 | 'URL' => 'Illuminate\Support\Facades\URL',
189 | 'Validator' => 'Illuminate\Support\Facades\Validator',
190 | 'View' => 'Illuminate\Support\Facades\View',
191 |
192 | ),
193 |
194 | );
195 |
--------------------------------------------------------------------------------
/app/config/auth.php:
--------------------------------------------------------------------------------
1 | 'eloquent',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Authentication Model
23 | |--------------------------------------------------------------------------
24 | |
25 | | When using the "Eloquent" authentication driver, we need to know which
26 | | Eloquent model should be used to retrieve your users. Of course, it
27 | | is often just the "User" model but you may use whatever you like.
28 | |
29 | */
30 |
31 | 'model' => 'User',
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | Authentication Table
36 | |--------------------------------------------------------------------------
37 | |
38 | | When using the "Database" authentication driver, we need to know which
39 | | table should be used to retrieve your users. We have chosen a basic
40 | | default value but you may easily change it to any table you like.
41 | |
42 | */
43 |
44 | 'table' => 'users',
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Password Reminder Settings
49 | |--------------------------------------------------------------------------
50 | |
51 | | Here you may set the settings for password reminders, including a view
52 | | that should be used as your password reminder e-mail. You will also
53 | | be able to set the name of the table that holds the reset tokens.
54 | |
55 | | The "expire" time is the number of minutes that the reminder should be
56 | | considered valid. This security feature keeps tokens short-lived so
57 | | they have less time to be guessed. You may change this as needed.
58 | |
59 | */
60 |
61 | 'reminder' => array(
62 |
63 | 'email' => 'emails.auth.reminder',
64 |
65 | 'table' => 'password_reminders',
66 |
67 | 'expire' => 60,
68 |
69 | ),
70 |
71 | );
72 |
--------------------------------------------------------------------------------
/app/config/cache.php:
--------------------------------------------------------------------------------
1 | 'file',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | File Cache Location
23 | |--------------------------------------------------------------------------
24 | |
25 | | When using the "file" cache driver, we need a location where the cache
26 | | files may be stored. A sensible default has been specified, but you
27 | | are free to change it to any other place on disk that you desire.
28 | |
29 | */
30 |
31 | 'path' => storage_path().'/cache',
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | Database Cache Connection
36 | |--------------------------------------------------------------------------
37 | |
38 | | When using the "database" cache driver you may specify the connection
39 | | that should be used to store the cached items. When this option is
40 | | null the default database connection will be utilized for cache.
41 | |
42 | */
43 |
44 | 'connection' => null,
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Database Cache Table
49 | |--------------------------------------------------------------------------
50 | |
51 | | When using the "database" cache driver we need to know the table that
52 | | should be used to store the cached items. A default table name has
53 | | been provided but you're free to change it however you deem fit.
54 | |
55 | */
56 |
57 | 'table' => 'cache',
58 |
59 | /*
60 | |--------------------------------------------------------------------------
61 | | Memcached Servers
62 | |--------------------------------------------------------------------------
63 | |
64 | | Now you may specify an array of your Memcached servers that should be
65 | | used when utilizing the Memcached cache driver. All of the servers
66 | | should contain a value for "host", "port", and "weight" options.
67 | |
68 | */
69 |
70 | 'memcached' => array(
71 |
72 | array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
73 |
74 | ),
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | Cache Key Prefix
79 | |--------------------------------------------------------------------------
80 | |
81 | | When utilizing a RAM based store such as APC or Memcached, there might
82 | | be other applications utilizing the same cache. So, we'll specify a
83 | | value to get prefixed to all our keys so we can avoid collisions.
84 | |
85 | */
86 |
87 | 'prefix' => 'laravel',
88 |
89 | );
90 |
--------------------------------------------------------------------------------
/app/config/compile.php:
--------------------------------------------------------------------------------
1 | PDO::FETCH_CLASS,
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Database Connection Name
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may specify which of the database connections below you wish
24 | | to use as your default connection for all database work. Of course
25 | | you may use many connections at once using the Database library.
26 | |
27 | */
28 |
29 | 'default' => 'mysql',
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Database Connections
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here are each of the database connections setup for your application.
37 | | Of course, examples of configuring each database platform that is
38 | | supported by Laravel is shown below to make development simple.
39 | |
40 | |
41 | | All database work in Laravel is done through the PHP PDO facilities
42 | | so make sure you have the driver for your particular database of
43 | | choice installed on your machine before you begin development.
44 | |
45 | */
46 |
47 | 'connections' => array(
48 |
49 | 'sqlite' => array(
50 | 'driver' => 'sqlite',
51 | 'database' => __DIR__.'/../database/production.sqlite',
52 | 'prefix' => '',
53 | ),
54 |
55 | 'mysql' => array(
56 | 'driver' => 'mysql',
57 | 'host' => 'localhost',
58 | 'database' => 'forge',
59 | 'username' => 'forge',
60 | 'password' => '',
61 | 'charset' => 'utf8',
62 | 'collation' => 'utf8_unicode_ci',
63 | 'prefix' => '',
64 | ),
65 |
66 | 'pgsql' => array(
67 | 'driver' => 'pgsql',
68 | 'host' => 'localhost',
69 | 'database' => 'forge',
70 | 'username' => 'forge',
71 | 'password' => '',
72 | 'charset' => 'utf8',
73 | 'prefix' => '',
74 | 'schema' => 'public',
75 | ),
76 |
77 | 'sqlsrv' => array(
78 | 'driver' => 'sqlsrv',
79 | 'host' => 'localhost',
80 | 'database' => 'database',
81 | 'username' => 'root',
82 | 'password' => '',
83 | 'prefix' => '',
84 | ),
85 |
86 | ),
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Migration Repository Table
91 | |--------------------------------------------------------------------------
92 | |
93 | | This table keeps track of all the migrations that have already run for
94 | | your application. Using this information, we can determine which of
95 | | the migrations on disk haven't actually been run in the database.
96 | |
97 | */
98 |
99 | 'migrations' => 'migrations',
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Redis Databases
104 | |--------------------------------------------------------------------------
105 | |
106 | | Redis is an open source, fast, and advanced key-value store that also
107 | | provides a richer set of commands than a typical key-value systems
108 | | such as APC or Memcached. Laravel makes it easy to dig right in.
109 | |
110 | */
111 |
112 | 'redis' => array(
113 |
114 | 'cluster' => false,
115 |
116 | 'default' => array(
117 | 'host' => '127.0.0.1',
118 | 'port' => 6379,
119 | 'database' => 0,
120 | ),
121 |
122 | ),
123 |
124 | );
125 |
--------------------------------------------------------------------------------
/app/config/local/app.php:
--------------------------------------------------------------------------------
1 | true,
17 |
18 | );
19 |
--------------------------------------------------------------------------------
/app/config/local/database.php:
--------------------------------------------------------------------------------
1 | array(
22 |
23 | 'mysql' => array(
24 | 'driver' => 'mysql',
25 | 'host' => 'localhost',
26 | 'database' => 'homestead',
27 | 'username' => 'homestead',
28 | 'password' => 'secret',
29 | 'charset' => 'utf8',
30 | 'collation' => 'utf8_unicode_ci',
31 | 'prefix' => '',
32 | ),
33 |
34 | 'pgsql' => array(
35 | 'driver' => 'pgsql',
36 | 'host' => 'localhost',
37 | 'database' => 'homestead',
38 | 'username' => 'homestead',
39 | 'password' => 'secret',
40 | 'charset' => 'utf8',
41 | 'prefix' => '',
42 | 'schema' => 'public',
43 | ),
44 |
45 | ),
46 |
47 | );
48 |
--------------------------------------------------------------------------------
/app/config/mail.php:
--------------------------------------------------------------------------------
1 | 'smtp',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | SMTP Host Address
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may provide the host address of the SMTP server used by your
26 | | applications. A default option is provided that is compatible with
27 | | the Mailgun mail service which will provide reliable deliveries.
28 | |
29 | */
30 |
31 | 'host' => 'smtp.mailgun.org',
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | SMTP Host Port
36 | |--------------------------------------------------------------------------
37 | |
38 | | This is the SMTP port used by your application to deliver e-mails to
39 | | users of the application. Like the host we have set this value to
40 | | stay compatible with the Mailgun e-mail application by default.
41 | |
42 | */
43 |
44 | 'port' => 587,
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Global "From" Address
49 | |--------------------------------------------------------------------------
50 | |
51 | | You may wish for all e-mails sent by your application to be sent from
52 | | the same address. Here, you may specify a name and address that is
53 | | used globally for all e-mails that are sent by your application.
54 | |
55 | */
56 |
57 | 'from' => array('address' => null, 'name' => null),
58 |
59 | /*
60 | |--------------------------------------------------------------------------
61 | | E-Mail Encryption Protocol
62 | |--------------------------------------------------------------------------
63 | |
64 | | Here you may specify the encryption protocol that should be used when
65 | | the application send e-mail messages. A sensible default using the
66 | | transport layer security protocol should provide great security.
67 | |
68 | */
69 |
70 | 'encryption' => 'tls',
71 |
72 | /*
73 | |--------------------------------------------------------------------------
74 | | SMTP Server Username
75 | |--------------------------------------------------------------------------
76 | |
77 | | If your SMTP server requires a username for authentication, you should
78 | | set it here. This will get used to authenticate with your server on
79 | | connection. You may also set the "password" value below this one.
80 | |
81 | */
82 |
83 | 'username' => null,
84 |
85 | /*
86 | |--------------------------------------------------------------------------
87 | | SMTP Server Password
88 | |--------------------------------------------------------------------------
89 | |
90 | | Here you may set the password required by your SMTP server to send out
91 | | messages from your application. This will be given to the server on
92 | | connection so that the application will be able to send messages.
93 | |
94 | */
95 |
96 | 'password' => null,
97 |
98 | /*
99 | |--------------------------------------------------------------------------
100 | | Sendmail System Path
101 | |--------------------------------------------------------------------------
102 | |
103 | | When using the "sendmail" driver to send e-mails, we will need to know
104 | | the path to where Sendmail lives on this server. A default path has
105 | | been provided here, which will work well on most of your systems.
106 | |
107 | */
108 |
109 | 'sendmail' => '/usr/sbin/sendmail -bs',
110 |
111 | /*
112 | |--------------------------------------------------------------------------
113 | | Mail "Pretend"
114 | |--------------------------------------------------------------------------
115 | |
116 | | When this option is enabled, e-mail will not actually be sent over the
117 | | web and will instead be written to your application's logs files so
118 | | you may inspect the message. This is great for local development.
119 | |
120 | */
121 |
122 | 'pretend' => false,
123 |
124 | );
125 |
--------------------------------------------------------------------------------
/app/config/packages/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sitepoint-editors/laravel_google_analytics/e1ab3e7aa78d12f7525925b736304c18a84fff84/app/config/packages/.gitkeep
--------------------------------------------------------------------------------
/app/config/queue.php:
--------------------------------------------------------------------------------
1 | 'sync',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Queue Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure the connection information for each server that
26 | | is used by your application. A default configuration has been added
27 | | for each back-end shipped with Laravel. You are free to add more.
28 | |
29 | */
30 |
31 | 'connections' => array(
32 |
33 | 'sync' => array(
34 | 'driver' => 'sync',
35 | ),
36 |
37 | 'beanstalkd' => array(
38 | 'driver' => 'beanstalkd',
39 | 'host' => 'localhost',
40 | 'queue' => 'default',
41 | 'ttr' => 60,
42 | ),
43 |
44 | 'sqs' => array(
45 | 'driver' => 'sqs',
46 | 'key' => 'your-public-key',
47 | 'secret' => 'your-secret-key',
48 | 'queue' => 'your-queue-url',
49 | 'region' => 'us-east-1',
50 | ),
51 |
52 | 'iron' => array(
53 | 'driver' => 'iron',
54 | 'host' => 'mq-aws-us-east-1.iron.io',
55 | 'token' => 'your-token',
56 | 'project' => 'your-project-id',
57 | 'queue' => 'your-queue-name',
58 | 'encrypt' => true,
59 | ),
60 |
61 | 'redis' => array(
62 | 'driver' => 'redis',
63 | 'queue' => 'default',
64 | ),
65 |
66 | ),
67 |
68 | /*
69 | |--------------------------------------------------------------------------
70 | | Failed Queue Jobs
71 | |--------------------------------------------------------------------------
72 | |
73 | | These options configure the behavior of failed queue job logging so you
74 | | can control which database and table are used to store the jobs that
75 | | have failed. You may change them to any database / table you wish.
76 | |
77 | */
78 |
79 | 'failed' => array(
80 |
81 | 'database' => 'mysql', 'table' => 'failed_jobs',
82 |
83 | ),
84 |
85 | );
86 |
--------------------------------------------------------------------------------
/app/config/remote.php:
--------------------------------------------------------------------------------
1 | 'production',
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Remote Server Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | These are the servers that will be accessible via the SSH task runner
24 | | facilities of Laravel. This feature radically simplifies executing
25 | | tasks on your servers, such as deploying out these applications.
26 | |
27 | */
28 |
29 | 'connections' => array(
30 |
31 | 'production' => array(
32 | 'host' => '',
33 | 'username' => '',
34 | 'password' => '',
35 | 'key' => '',
36 | 'keyphrase' => '',
37 | 'root' => '/var/www',
38 | ),
39 |
40 | ),
41 |
42 | /*
43 | |--------------------------------------------------------------------------
44 | | Remote Server Groups
45 | |--------------------------------------------------------------------------
46 | |
47 | | Here you may list connections under a single group name, which allows
48 | | you to easily access all of the servers at once using a short name
49 | | that is extremely easy to remember, such as "web" or "database".
50 | |
51 | */
52 |
53 | 'groups' => array(
54 |
55 | 'web' => array('production')
56 |
57 | ),
58 |
59 | );
60 |
--------------------------------------------------------------------------------
/app/config/services.php:
--------------------------------------------------------------------------------
1 | array(
18 | 'domain' => '',
19 | 'secret' => '',
20 | ),
21 |
22 | 'mandrill' => array(
23 | 'secret' => '',
24 | ),
25 |
26 | 'stripe' => array(
27 | 'model' => 'User',
28 | 'secret' => '',
29 | ),
30 |
31 | );
32 |
--------------------------------------------------------------------------------
/app/config/session.php:
--------------------------------------------------------------------------------
1 | 'file',
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Session Lifetime
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may specify the number of minutes that you wish the session
27 | | to be allowed to remain idle before it expires. If you want them
28 | | to immediately expire on the browser closing, set that option.
29 | |
30 | */
31 |
32 | 'lifetime' => 120,
33 |
34 | 'expire_on_close' => false,
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | Session File Location
39 | |--------------------------------------------------------------------------
40 | |
41 | | When using the native session driver, we need a location where session
42 | | files may be stored. A default has been set for you but a different
43 | | location may be specified. This is only needed for file sessions.
44 | |
45 | */
46 |
47 | 'files' => storage_path().'/sessions',
48 |
49 | /*
50 | |--------------------------------------------------------------------------
51 | | Session Database Connection
52 | |--------------------------------------------------------------------------
53 | |
54 | | When using the "database" or "redis" session drivers, you may specify a
55 | | connection that should be used to manage these sessions. This should
56 | | correspond to a connection in your database configuration options.
57 | |
58 | */
59 |
60 | 'connection' => null,
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Session Database Table
65 | |--------------------------------------------------------------------------
66 | |
67 | | When using the "database" session driver, you may specify the table we
68 | | should use to manage the sessions. Of course, a sensible default is
69 | | provided for you; however, you are free to change this as needed.
70 | |
71 | */
72 |
73 | 'table' => 'sessions',
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Session Sweeping Lottery
78 | |--------------------------------------------------------------------------
79 | |
80 | | Some session drivers must manually sweep their storage location to get
81 | | rid of old sessions from storage. Here are the chances that it will
82 | | happen on a given request. By default, the odds are 2 out of 100.
83 | |
84 | */
85 |
86 | 'lottery' => array(2, 100),
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Session Cookie Name
91 | |--------------------------------------------------------------------------
92 | |
93 | | Here you may change the name of the cookie used to identify a session
94 | | instance by ID. The name specified here will get used every time a
95 | | new session cookie is created by the framework for every driver.
96 | |
97 | */
98 |
99 | 'cookie' => 'laravel_session',
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Session Cookie Path
104 | |--------------------------------------------------------------------------
105 | |
106 | | The session cookie path determines the path for which the cookie will
107 | | be regarded as available. Typically, this will be the root path of
108 | | your application but you are free to change this when necessary.
109 | |
110 | */
111 |
112 | 'path' => '/',
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Session Cookie Domain
117 | |--------------------------------------------------------------------------
118 | |
119 | | Here you may change the domain of the cookie used to identify a session
120 | | in your application. This will determine which domains the cookie is
121 | | available to in your application. A sensible default has been set.
122 | |
123 | */
124 |
125 | 'domain' => null,
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | HTTPS Only Cookies
130 | |--------------------------------------------------------------------------
131 | |
132 | | By setting this option to true, session cookies will only be sent back
133 | | to the server if the browser has a HTTPS connection. This will keep
134 | | the cookie from being sent to you if it can not be done securely.
135 | |
136 | */
137 |
138 | 'secure' => false,
139 |
140 | );
141 |
--------------------------------------------------------------------------------
/app/config/testing/cache.php:
--------------------------------------------------------------------------------
1 | 'array',
19 |
20 | );
21 |
--------------------------------------------------------------------------------
/app/config/testing/session.php:
--------------------------------------------------------------------------------
1 | 'array',
20 |
21 | );
22 |
--------------------------------------------------------------------------------
/app/config/view.php:
--------------------------------------------------------------------------------
1 | array(__DIR__.'/../views'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Pagination View
21 | |--------------------------------------------------------------------------
22 | |
23 | | This view will be used to render the pagination link output, and can
24 | | be easily customized here to show any view you like. A clean view
25 | | compatible with Twitter's Bootstrap is given to you by default.
26 | |
27 | */
28 |
29 | 'pagination' => 'pagination::slider-3',
30 |
31 | );
32 |
--------------------------------------------------------------------------------
/app/config/workbench.php:
--------------------------------------------------------------------------------
1 | '',
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Workbench Author E-Mail Address
21 | |--------------------------------------------------------------------------
22 | |
23 | | Like the option above, your e-mail address is used when generating new
24 | | workbench packages. The e-mail is placed in your composer.json file
25 | | automatically after the package is created by the workbench tool.
26 | |
27 | */
28 |
29 | 'email' => '',
30 |
31 | );
32 |
--------------------------------------------------------------------------------
/app/controllers/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sitepoint-editors/laravel_google_analytics/e1ab3e7aa78d12f7525925b736304c18a84fff84/app/controllers/.gitkeep
--------------------------------------------------------------------------------
/app/controllers/BaseController.php:
--------------------------------------------------------------------------------
1 | layout))
13 | {
14 | $this->layout = View::make($this->layout);
15 | }
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/app/controllers/HomeController.php:
--------------------------------------------------------------------------------
1 | ga = $ga;
12 | }
13 |
14 | public function index()
15 | {
16 | if ($this->ga->isLoggedIn()) {
17 | $metadata = $this->metadata();
18 | $dimensions = $metadata['dimensions'];
19 | $metrics = $metadata['metrics'];
20 |
21 | return View::make('home', [
22 | 'dimensions' => $dimensions,
23 | 'metrics' => $metrics
24 | ]);
25 | }//if
26 | else {
27 | $url = $this->ga->getLoginUrl();
28 |
29 | return View::make('login', ['url' => $url]);
30 | }
31 | }//index
32 |
33 | public function login()
34 | {
35 | if (Input::has('code')) {
36 | $code = Input::get('code');
37 |
38 | $this->ga->login($code);
39 |
40 | return "Go to the home page";
41 | } else {
42 | return "Invalide request parameters";
43 | }//else
44 | }//login
45 |
46 | public function segments()
47 | {
48 | $segments = $this->ga->segments();
49 |
50 | return $segments;
51 | }//segments
52 |
53 | public function accounts()
54 | {
55 | $accounts = $this->ga->accounts();
56 |
57 | return $accounts;
58 | }//accounts
59 |
60 | public function properties($account_id)
61 | {
62 | $properties = $this->ga->properties($account_id);
63 |
64 | return $properties;
65 | }//properties
66 |
67 | public function views($account_id, $property_id)
68 | {
69 | $views = $this->ga->views($account_id, $property_id);
70 |
71 | return $views;
72 | }//views
73 |
74 | public function metadata()
75 | {
76 | $metadata = $this->ga->metadata();
77 |
78 | return $metadata;
79 | }//metadata
80 |
81 | public function report()
82 | {
83 | if (!$this->ga->isLoggedIn()) {
84 | return Response::json([
85 | 'status' => 0,
86 | 'code' => 1,
87 | 'message' => 'Login required'
88 | ]);
89 | }
90 |
91 | if (!Input::has('dimensions') || !Input::has('metrics') || !Input::has('view')) {
92 | return Response::json([
93 | 'status' => 0,
94 | 'code' => 1,
95 | 'message' => 'Invalid request parametter'
96 | ]);
97 | }
98 |
99 | $view = 'ga:' . Input::get('view');
100 | $dimensions = Input::get('dimensions');
101 | $metrics = Input::get('metrics');
102 |
103 | $daterange = explode(' - ', Input::get('daterange'));
104 | $start_date = $daterange[0];
105 | $end_date = $daterange[1];
106 |
107 | $max_results = intval(Input::get('max_results'));
108 |
109 |
110 | $filters = [];
111 | $group_filters = [];
112 | $group_filters['dimensions'] = GA_Utils::groupFilters(
113 | Input::get('dimension_filter_show'),
114 | Input::get('dimension_filters'),
115 | Input::get('dimension_filter_rules'),
116 | Input::get('dimension_filter_values')
117 | );
118 | $tmp = GA_Utils::encodeDimensionFilters($group_filters['dimensions']);
119 |
120 | if (!empty($tmp)) {
121 | $filters[] = $tmp;
122 | }
123 |
124 |
125 | $group_filters['metrics'] = GA_Utils::groupFilters(
126 | Input::get('metric_filter_show'),
127 | Input::get('metric_filters'),
128 | Input::get('metric_filter_rules'),
129 | Input::get('metric_filter_values')
130 | );
131 |
132 | $tmp = GA_Utils::encodeMetricFilters($group_filters['metrics']);
133 |
134 | if (!empty($tmp)) {
135 | $filters[] = $tmp;
136 | }
137 |
138 | //dimension and filters cannot be combined using the OR operator (,)
139 | $filters = implode(';', $filters);
140 | $orderbys = null;
141 |
142 | if (Input::has('orderbys')) {
143 | $orderbys = GA_Utils::encodeOrderby(GA_Utils::groupOrderby(Input::get('orderbys'), Input::get('orderby_rules')));
144 | }
145 |
146 |
147 | $report = $this->ga->report($view, $start_date, $end_date, $max_results, $dimensions, $metrics, $filters,
148 | $orderbys);
149 |
150 | $json_data = [];
151 | foreach ($report['items'] as $item) {
152 | $json_data[] = [
153 | 'name' => $item[0],
154 | 'y' => (int)$item[1]
155 | ];
156 | }//foreach
157 |
158 | return View::make('report', [
159 | 'columns' => $report['columnHeaders'],
160 | 'items' => $report['items'],
161 | 'totalResults' => $report['totalResults'],
162 | 'report_json' => json_encode($json_data),
163 | 'chart_type' => Input::get('chart_type')
164 | ]);
165 | }//report
166 |
167 | }//class
--------------------------------------------------------------------------------
/app/database/migrations/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sitepoint-editors/laravel_google_analytics/e1ab3e7aa78d12f7525925b736304c18a84fff84/app/database/migrations/.gitkeep
--------------------------------------------------------------------------------
/app/database/production.sqlite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sitepoint-editors/laravel_google_analytics/e1ab3e7aa78d12f7525925b736304c18a84fff84/app/database/production.sqlite
--------------------------------------------------------------------------------
/app/database/seeds/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sitepoint-editors/laravel_google_analytics/e1ab3e7aa78d12f7525925b736304c18a84fff84/app/database/seeds/.gitkeep
--------------------------------------------------------------------------------
/app/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call('UserTableSeeder');
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/app/filters.php:
--------------------------------------------------------------------------------
1 | '« Previous',
17 |
18 | 'next' => 'Next »',
19 |
20 | );
21 |
--------------------------------------------------------------------------------
/app/lang/en/reminders.php:
--------------------------------------------------------------------------------
1 | "Passwords must be at least six characters and match the confirmation.",
17 |
18 | "user" => "We can't find a user with that e-mail address.",
19 |
20 | "token" => "This password reset token is invalid.",
21 |
22 | "sent" => "Password reminder sent!",
23 |
24 | );
25 |
--------------------------------------------------------------------------------
/app/lang/en/validation.php:
--------------------------------------------------------------------------------
1 | "The :attribute must be accepted.",
17 | "active_url" => "The :attribute is not a valid URL.",
18 | "after" => "The :attribute must be a date after :date.",
19 | "alpha" => "The :attribute may only contain letters.",
20 | "alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.",
21 | "alpha_num" => "The :attribute may only contain letters and numbers.",
22 | "array" => "The :attribute must be an array.",
23 | "before" => "The :attribute must be a date before :date.",
24 | "between" => array(
25 | "numeric" => "The :attribute must be between :min and :max.",
26 | "file" => "The :attribute must be between :min and :max kilobytes.",
27 | "string" => "The :attribute must be between :min and :max characters.",
28 | "array" => "The :attribute must have between :min and :max items.",
29 | ),
30 | "confirmed" => "The :attribute confirmation does not match.",
31 | "date" => "The :attribute is not a valid date.",
32 | "date_format" => "The :attribute does not match the format :format.",
33 | "different" => "The :attribute and :other must be different.",
34 | "digits" => "The :attribute must be :digits digits.",
35 | "digits_between" => "The :attribute must be between :min and :max digits.",
36 | "email" => "The :attribute must be a valid email address.",
37 | "exists" => "The selected :attribute is invalid.",
38 | "image" => "The :attribute must be an image.",
39 | "in" => "The selected :attribute is invalid.",
40 | "integer" => "The :attribute must be an integer.",
41 | "ip" => "The :attribute must be a valid IP address.",
42 | "max" => array(
43 | "numeric" => "The :attribute may not be greater than :max.",
44 | "file" => "The :attribute may not be greater than :max kilobytes.",
45 | "string" => "The :attribute may not be greater than :max characters.",
46 | "array" => "The :attribute may not have more than :max items.",
47 | ),
48 | "mimes" => "The :attribute must be a file of type: :values.",
49 | "min" => array(
50 | "numeric" => "The :attribute must be at least :min.",
51 | "file" => "The :attribute must be at least :min kilobytes.",
52 | "string" => "The :attribute must be at least :min characters.",
53 | "array" => "The :attribute must have at least :min items.",
54 | ),
55 | "not_in" => "The selected :attribute is invalid.",
56 | "numeric" => "The :attribute must be a number.",
57 | "regex" => "The :attribute format is invalid.",
58 | "required" => "The :attribute field is required.",
59 | "required_if" => "The :attribute field is required when :other is :value.",
60 | "required_with" => "The :attribute field is required when :values is present.",
61 | "required_with_all" => "The :attribute field is required when :values is present.",
62 | "required_without" => "The :attribute field is required when :values is not present.",
63 | "required_without_all" => "The :attribute field is required when none of :values are present.",
64 | "same" => "The :attribute and :other must match.",
65 | "size" => array(
66 | "numeric" => "The :attribute must be :size.",
67 | "file" => "The :attribute must be :size kilobytes.",
68 | "string" => "The :attribute must be :size characters.",
69 | "array" => "The :attribute must contain :size items.",
70 | ),
71 | "unique" => "The :attribute has already been taken.",
72 | "url" => "The :attribute format is invalid.",
73 |
74 | /*
75 | |--------------------------------------------------------------------------
76 | | Custom Validation Language Lines
77 | |--------------------------------------------------------------------------
78 | |
79 | | Here you may specify custom validation messages for attributes using the
80 | | convention "attribute.rule" to name the lines. This makes it quick to
81 | | specify a specific custom language line for a given attribute rule.
82 | |
83 | */
84 |
85 | 'custom' => array(
86 | 'attribute-name' => array(
87 | 'rule-name' => 'custom-message',
88 | ),
89 | ),
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Custom Validation Attributes
94 | |--------------------------------------------------------------------------
95 | |
96 | | The following language lines are used to swap attribute place-holders
97 | | with something more reader friendly such as E-Mail Address instead
98 | | of "email". This simply helps us make messages a little cleaner.
99 | |
100 | */
101 |
102 | 'attributes' => array(),
103 |
104 | );
105 |
--------------------------------------------------------------------------------
/app/models/User.php:
--------------------------------------------------------------------------------
1 | 'HomeController@properties'])->where('account_id', '\d+');
10 | Route::get('/views/{account_id}/{property_id}', ['uses' => 'HomeController@views'])->where([
11 | 'account_id',
12 | '\d+',
13 | 'property_id',
14 | '\d+'
15 | ]);
16 |
17 | //metadata
18 | Route::get('/metadata', 'HomeController@metadata');
19 |
20 | //reporting
21 | Route::post('/report', 'HomeController@report');
--------------------------------------------------------------------------------
/app/src/GA_Service.php:
--------------------------------------------------------------------------------
1 | client = $client;
12 | $this->init();
13 | }
14 |
15 | private function init()
16 | {
17 | $this->client->setClientId(Config::get('analytics.client_id'));
18 | $this->client->setClientSecret(Config::get('analytics.client_secret'));
19 | $this->client->setDeveloperKey(Config::get('analytics.api_key'));
20 | $this->client->setRedirectUri('http://localhost:8000/login');
21 | $this->client->setScopes(['https://www.googleapis.com/auth/analytics']);
22 | //$this->client->setUseObjects(true);
23 | }
24 |
25 | public function isLoggedIn()
26 | {
27 |
28 | if (Session::has('token')) {
29 | $this->client->setAccessToken(Session::get('token'));
30 | }
31 |
32 | return $this->client->getAccessToken();
33 | }//authenticate
34 |
35 | public function login($code)
36 | {
37 |
38 | $this->client->authenticate($code);
39 | $token = $this->client->getAccessToken();
40 | Session::put('token', $token);
41 |
42 | return $token;
43 | }//login
44 |
45 | public function getLoginUrl()
46 | {
47 | $authUrl = $this->client->createAuthUrl();
48 |
49 | return $authUrl;
50 | }//getLoginUrl
51 |
52 | public function segments()
53 | {
54 | if (!$this->isLoggedIn()) {
55 | //login
56 | }
57 |
58 | $service = new Google_Service_Analytics($this->client);
59 | $segments = $service->management_segments->listManagementSegments();
60 |
61 | return $segments;
62 | }//segments
63 |
64 | public function accounts()
65 | {
66 | if (!$this->isLoggedIn()) {
67 | //login
68 | }
69 |
70 | $service = new Google_Service_Analytics($this->client);
71 |
72 | $man_accounts = $service->management_accounts->listManagementAccounts();
73 | $accounts = [];
74 |
75 | foreach ($man_accounts['items'] as $account) {
76 | $accounts[] = ['id' => $account['id'], 'name' => $account['name']];
77 | }
78 |
79 | return $accounts;
80 | }//accounts
81 |
82 | public function properties($account_id)
83 | {
84 | if (!$this->isLoggedIn()) {
85 | //login
86 | }
87 |
88 | try {
89 | $service = new Google_Service_Analytics($this->client);
90 | $man_properties = $service->management_webproperties->listManagementWebproperties($account_id);
91 | $properties = [];
92 |
93 | foreach ($man_properties['items'] as $property) {
94 | $properties[] = ['id' => $property['id'], 'name' => $property['name']];
95 | }//foreach
96 |
97 | return json_encode($properties);
98 | } catch (Google_Service_Exception $e) {
99 | return Response::json([
100 | 'status' => 0,
101 | 'code' => 3,
102 | 'message' => $e->getMessage()
103 | ]);
104 | }//catch
105 |
106 | }//properties
107 |
108 | public function views($account_id, $property_id)
109 | {
110 | if (!$this->isLoggedIn()) {
111 | //login
112 | }
113 |
114 | try {
115 | $service = new Google_Service_Analytics($this->client);
116 | $man_views = $service->management_profiles->listManagementProfiles($account_id, $property_id);
117 | $views = [];
118 |
119 | foreach ($man_views['items'] as $view) {
120 | $views[] = ['id' => $view['id'], 'name' => $view['name']];
121 | }//foreach
122 |
123 | return json_encode($views);
124 | } catch (Google_Service_Exception $e) {
125 | return Response::json([
126 | 'status' => 0,
127 | 'code' => 3,
128 | 'message' => $e->getMessage()
129 | ]);
130 | }//catch
131 | }//views
132 |
133 | public function metadata()
134 | {
135 | $gcurl = new Google_IO_Curl($this->client);
136 | $response = $gcurl->makeRequest(
137 | new Google_Http_Request("https://www.googleapis.com/analytics/v3/metadata/ga/columns")
138 | );
139 |
140 | //verify returned data
141 | $data = json_decode($response->getResponseBody());
142 |
143 | $items = $data->items;
144 | $data_items = [];
145 | $dimensions_data = [];
146 | $metrics_data = [];
147 |
148 | foreach ($items as $item) {
149 | if ($item->attributes->status == 'DEPRECATED') {
150 | continue;
151 | }
152 |
153 | if ($item->attributes->type == 'DIMENSION') {
154 | $dimensions_data[$item->attributes->group][] = $item;
155 | }
156 |
157 | if ($item->attributes->type == 'METRIC') {
158 | $metrics_data[$item->attributes->group][] = $item;
159 | }
160 | }//foreach
161 |
162 | $data_items['dimensions'] = $dimensions_data;
163 | $data_items['metrics'] = $metrics_data;
164 |
165 | return $data_items;
166 | }//metadata
167 |
168 | public function report($view, $start_date, $end_date, $max_results, $dimensions, $metrics, $filters, $orderbys)
169 | {
170 | $dimensions = implode(",", $dimensions);
171 | $metrics = implode(",", $metrics);
172 |
173 | try {
174 | $analytics = new Google_Service_Analytics($this->client);
175 | $options = [];
176 |
177 | $options['dimensions'] = $dimensions;
178 | $options['max-results'] = $max_results;
179 |
180 | if (!empty($filters)) {
181 | $options['filters'] = $filters;
182 | }
183 |
184 | $options['sort'] = $orderbys;
185 |
186 | $data = $analytics->data_ga->get($view, $start_date, $end_date, $metrics,
187 | $options
188 | );
189 |
190 | $res = [
191 | 'items' => isset($data['rows']) ? $data['rows'] : [],
192 | 'columnHeaders' => $data['columnHeaders'],
193 | 'totalResults' => $data['totalResults']
194 | ];
195 |
196 | } catch (Google_Service_Exception $ex) {
197 | return Response::json([
198 | 'status' => 0,
199 | 'code' => 2,
200 | 'message' => 'Google analytics internal server error: (Technical details) ' . $ex->getErrors()[0]['message']
201 | ]);
202 | }//catch
203 |
204 | return $res;
205 | }//report
206 | }//class
207 |
--------------------------------------------------------------------------------
/app/src/GA_Utils.php:
--------------------------------------------------------------------------------
1 | ';
65 | } else {
66 | $operator = '<';
67 | }
68 | } else {
69 | if ($filter['rule'] == "lt") {
70 | if ($filter['show'] == "show") {
71 | $operator = '<';
72 | } else {
73 | $operator = '>';
74 | }
75 | } else {
76 | if ($filter['rule'] == "gteq") {
77 | if ($filter['show'] == "show") {
78 | $operator = '>=';
79 | } else {
80 | $operator = '<=';
81 | }
82 | } else {
83 | if ($filter['rule'] == "lteq") {
84 | if ($filter['show'] == "show") {
85 | $operator = '<=';
86 | } else {
87 | $operator = '>=';
88 | }
89 | }
90 | }
91 | }
92 | }
93 | }
94 |
95 |
96 | $url[] = "{$filter['column']}{$operator}{$filter['val']}";
97 | }//foreach
98 |
99 | $uri = implode(";", $url);
100 |
101 | return $uri;
102 | }//encodeMetricFilters
103 |
104 | public static function groupFilters(array $show, array $filters, array $rules, array $values)
105 | {
106 | $count = count($filters);
107 | $group_filters = [];
108 |
109 | for ($i = 0; $i < $count; $i++) {
110 | // skip if no value is provided
111 | if (empty($values[$i])) {
112 | continue;
113 | }
114 |
115 | $group_filters[] = [
116 | 'show' => $show[$i],
117 | 'column' => $filters[$i],
118 | 'rule' => $rules[$i],
119 | 'val' => $values[$i]
120 | ];
121 | }//for
122 |
123 | return $group_filters;
124 | }//groupFilters
125 |
126 | public static function groupOrderby(array $orderbys, array $rules)
127 | {
128 | $count = count($orderbys);
129 | $group_orderbys = [];
130 |
131 | for ($i = 0; $i < $count; $i++) {
132 | $group_orderbys[] = [
133 | 'column' => $orderbys[$i],
134 | 'rule' => $rules[$i]
135 | ];
136 | }//for
137 |
138 | return $group_orderbys;
139 | }//groupOrderby
140 |
141 | public static function encodeOrderby($orderbys)
142 | {
143 | $res = [];
144 |
145 | foreach ($orderbys as $orderby) {
146 | $res[] = $orderby['rule'] . $orderby['column'];
147 | }//foreach
148 |
149 | return implode(',', $res);
150 | }//encodeOrderby
151 | }//class
152 |
--------------------------------------------------------------------------------
/app/start/artisan.php:
--------------------------------------------------------------------------------
1 | client->request('GET', '/');
13 |
14 | $this->assertTrue($this->client->getResponse()->isOk());
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/app/tests/TestCase.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
Password Reset
8 |
9 |
10 | To reset your password, complete this form: {{ URL::to('password/reset', array($token)) }}.
11 | This link will expire in {{ Config::get('auth.reminder.expire', 60) }} minutes.
12 |