├── .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 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /app/views/hello.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Laravel PHP Framework 6 | 35 | 36 | 37 |
38 | Laravel PHP Framework 39 |

You have arrived.

40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /app/views/home.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Google Analytics 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 39 | 195 | 196 | 197 |
198 |
199 |
200 |
201 |
202 |
203 | 204 | Google Analytics explorer 205 | 206 |
207 | 208 |
209 | 212 |
213 |
214 | 215 |
216 | 217 |
218 | 221 |
222 |
223 | 224 |
225 | 226 |
227 | 230 |
231 |
232 | 233 |
234 | 235 |
236 | 245 |
246 |
247 | 248 |
249 | 250 |
251 | 260 |
261 |
262 | 263 |
264 | 265 |
266 | 267 |
268 |
269 | 270 |
271 | 272 |
273 | 274 |
275 |
276 | 277 |
278 | 279 |
280 | 284 |
285 |
286 | 287 |
288 |
289 |
Dimensions Filter
290 | 291 |
292 | 293 |
294 | 295 |
    296 |
  • 297 |
    298 | 302 |
    303 |
    304 | 313 |
    314 | 315 |
    316 | 321 |
    322 | 323 |
    324 | 325 |
    326 | 327 |
    328 | 329 |
    330 |
  • 331 |
332 | 333 |
334 |
335 | 336 |
337 |
338 |
Metrics Filter
339 | 340 |
341 |
342 | 343 |
    344 |
  • 345 |
    346 | 350 |
    351 | 352 |
    353 | 362 |
    363 | 364 |
    365 | 372 |
    373 | 374 |
    375 | 376 |
    377 | 378 |
    379 | 380 |
    381 |
  • 382 |
383 | 384 |
385 |
386 | 387 |
388 |
389 |
Order By
390 | 391 |
392 |
393 | 394 |
    395 | 396 |
397 | 398 |
399 |
400 | 401 |
402 |
403 |
404 | 405 |
406 |
407 |
408 | 409 |
410 |
411 |
412 |
413 |
414 | 415 | -------------------------------------------------------------------------------- /app/views/login.blade.php: -------------------------------------------------------------------------------- 1 | Login -------------------------------------------------------------------------------- /app/views/report.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Google Analytics 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 |
16 |

total results: {{ $totalResults }}

17 | @if( $chart_type == 'pie' ) 18 |
19 |
20 |
21 | 22 | 62 | @else 63 | 64 | 65 | @foreach ($columns as $column) 66 | 67 | @endforeach 68 | 69 | @foreach ($items as $item) 70 | 71 | @foreach ($item as $it) 72 | 73 | @endforeach 74 | 75 | @endforeach 76 |
{{ $column['name'] }}
{{ $it }}
77 | @endif 78 | 79 |
80 | 81 |
82 | 83 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | setRequestForConsoleEnvironment(); 45 | 46 | $artisan = Illuminate\Console\Application::start($app); 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Run The Artisan Application 51 | |-------------------------------------------------------------------------- 52 | | 53 | | When we run the console application, the current CLI command will be 54 | | executed in this console and the response sent back to a terminal 55 | | or another output device for the developers. Here goes nothing! 56 | | 57 | */ 58 | 59 | $status = $artisan->run(); 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Shutdown The Application 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Once Artisan has finished running. We will fire off the shutdown events 67 | | so that any final work may be done by the application before we shut 68 | | down the process. This is the last thing to happen to the request. 69 | | 70 | */ 71 | 72 | $app->shutdown(); 73 | 74 | exit($status); 75 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | __DIR__.'/../app', 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Public Path 21 | |-------------------------------------------------------------------------- 22 | | 23 | | The public path contains the assets for your web application, such as 24 | | your JavaScript and CSS files, and also contains the primary entry 25 | | point for web requests into these applications from the outside. 26 | | 27 | */ 28 | 29 | 'public' => __DIR__.'/../public', 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Base Path 34 | |-------------------------------------------------------------------------- 35 | | 36 | | The base path is the root of the Laravel installation. Most likely you 37 | | will not need to change this value. But, if for some wild reason it 38 | | is necessary you will do so here, just proceed with some caution. 39 | | 40 | */ 41 | 42 | 'base' => __DIR__.'/..', 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Storage Path 47 | |-------------------------------------------------------------------------- 48 | | 49 | | The storage path is used by Laravel to store cached Blade views, logs 50 | | and other pieces of information. You may modify the path here when 51 | | you want to change the location of this directory for your apps. 52 | | 53 | */ 54 | 55 | 'storage' => __DIR__.'/../app/storage', 56 | 57 | ); 58 | -------------------------------------------------------------------------------- /bootstrap/start.php: -------------------------------------------------------------------------------- 1 | detectEnvironment(array( 28 | 29 | 'local' => array('homestead'), 30 | 31 | )); 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Bind Paths 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Here we are binding the paths configured in paths.php to the app. You 39 | | should not be changing these here. If you need to change these you 40 | | may do so within the paths.php file and they will be bound here. 41 | | 42 | */ 43 | 44 | $app->bindInstallPaths(require __DIR__.'/paths.php'); 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Load The Application 49 | |-------------------------------------------------------------------------- 50 | | 51 | | Here we will load this Illuminate application. We will keep this in a 52 | | separate location so we can isolate the creation of an application 53 | | from the actual running of the application with a given request. 54 | | 55 | */ 56 | 57 | $framework = $app['path.base']. 58 | '/vendor/laravel/framework/src'; 59 | 60 | require $framework.'/Illuminate/Foundation/start.php'; 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Return The Application 65 | |-------------------------------------------------------------------------- 66 | | 67 | | This script returns the application instance. The instance is given to 68 | | the calling script so we can separate the building of the instances 69 | | from the actual running of the application and sending responses. 70 | | 71 | */ 72 | 73 | return $app; 74 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "require": { 7 | "laravel/framework": "4.2.*", 8 | "google/apiclient": "1.1.*" 9 | }, 10 | "autoload": { 11 | "classmap": [ 12 | "app/commands", 13 | "app/controllers", 14 | "app/models", 15 | "app/database/migrations", 16 | "app/database/seeds", 17 | "app/tests/TestCase.php", 18 | "app/src" 19 | ] 20 | }, 21 | "scripts": { 22 | "post-install-cmd": [ 23 | "php artisan clear-compiled", 24 | "php artisan optimize" 25 | ], 26 | "post-update-cmd": [ 27 | "php artisan clear-compiled", 28 | "php artisan optimize" 29 | ], 30 | "post-create-project-cmd": [ 31 | "php artisan key:generate" 32 | ] 33 | }, 34 | "config": { 35 | "preferred-install": "dist" 36 | }, 37 | "minimum-stability": "stable" 38 | } 39 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./app/tests/ 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes... 9 | RewriteRule ^(.*)/$ /$1 [L,R=301] 10 | 11 | # Handle Front Controller... 12 | RewriteCond %{REQUEST_FILENAME} !-d 13 | RewriteCond %{REQUEST_FILENAME} !-f 14 | RewriteRule ^ index.php [L] 15 | 16 | -------------------------------------------------------------------------------- /public/css/daterangepicker-bs2.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Stylesheet for the Date Range Picker, for use with Bootstrap 2.x 3 | * 4 | * Copyright 2013 Dan Grossman ( http://www.dangrossman.info ) 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Built for http://www.improvely.com 9 | */ 10 | 11 | .daterangepicker.dropdown-menu { 12 | max-width: none; 13 | z-index: 3000; 14 | } 15 | 16 | .daterangepicker.opensleft .ranges, .daterangepicker.opensleft .calendar { 17 | float: left; 18 | margin: 4px; 19 | } 20 | 21 | .daterangepicker.opensright .ranges, .daterangepicker.opensright .calendar, 22 | .daterangepicker.openscenter .ranges, .daterangepicker.openscenter .calendar { 23 | float: right; 24 | margin: 4px; 25 | } 26 | 27 | .daterangepicker .ranges { 28 | width: 160px; 29 | text-align: left; 30 | } 31 | 32 | .daterangepicker .ranges .range_inputs>div { 33 | float: left; 34 | } 35 | 36 | .daterangepicker .ranges .range_inputs>div:nth-child(2) { 37 | padding-left: 11px; 38 | } 39 | 40 | .daterangepicker .calendar { 41 | display: none; 42 | max-width: 250px; 43 | } 44 | .daterangepicker.show-calendar .calendar { 45 | display: block; 46 | } 47 | 48 | .daterangepicker .calendar.single .calendar-date { 49 | border: none; 50 | } 51 | 52 | .daterangepicker .calendar th, .daterangepicker .calendar td { 53 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 54 | white-space: nowrap; 55 | text-align: center; 56 | } 57 | 58 | .daterangepicker .daterangepicker_start_input label, 59 | .daterangepicker .daterangepicker_end_input label { 60 | color: #333; 61 | font-size: 11px; 62 | margin-bottom: 2px; 63 | text-transform: uppercase; 64 | text-shadow: 1px 1px 0 #fff; 65 | } 66 | 67 | .daterangepicker .ranges input { 68 | font-size: 11px; 69 | } 70 | 71 | .daterangepicker .ranges ul { 72 | list-style: none; 73 | margin: 0; 74 | padding: 0; 75 | } 76 | 77 | .daterangepicker .ranges li { 78 | font-size: 13px; 79 | background: #f5f5f5; 80 | border: 1px solid #f5f5f5; 81 | color: #08c; 82 | padding: 3px 12px; 83 | margin-bottom: 8px; 84 | -webkit-border-radius: 5px; 85 | -moz-border-radius: 5px; 86 | border-radius: 5px; 87 | cursor: pointer; 88 | } 89 | 90 | .daterangepicker .ranges li.active, .daterangepicker .ranges li:hover { 91 | background: #08c; 92 | border: 1px solid #08c; 93 | color: #fff; 94 | } 95 | 96 | .daterangepicker .calendar-date { 97 | border: 1px solid #ddd; 98 | padding: 4px; 99 | border-radius: 4px; 100 | background: #fff; 101 | } 102 | 103 | .daterangepicker .calendar-time { 104 | text-align: center; 105 | margin: 8px auto 0 auto; 106 | line-height: 30px; 107 | } 108 | 109 | .daterangepicker { 110 | position: absolute; 111 | background: #fff; 112 | top: 100px; 113 | left: 20px; 114 | padding: 4px; 115 | margin-top: 1px; 116 | -webkit-border-radius: 4px; 117 | -moz-border-radius: 4px; 118 | border-radius: 4px; 119 | } 120 | 121 | .daterangepicker.opensleft:before { 122 | position: absolute; 123 | top: -7px; 124 | right: 9px; 125 | display: inline-block; 126 | border-right: 7px solid transparent; 127 | border-bottom: 7px solid #ccc; 128 | border-left: 7px solid transparent; 129 | border-bottom-color: rgba(0, 0, 0, 0.2); 130 | content: ''; 131 | } 132 | 133 | .daterangepicker.opensleft:after { 134 | position: absolute; 135 | top: -6px; 136 | right: 10px; 137 | display: inline-block; 138 | border-right: 6px solid transparent; 139 | border-bottom: 6px solid #fff; 140 | border-left: 6px solid transparent; 141 | content: ''; 142 | } 143 | 144 | .daterangepicker.openscenter:before { 145 | position: absolute; 146 | top: -7px; 147 | left: 0; 148 | right: 0; 149 | width: 0; 150 | margin-left: auto; 151 | margin-right: auto; 152 | display: inline-block; 153 | border-right: 7px solid transparent; 154 | border-bottom: 7px solid #ccc; 155 | border-left: 7px solid transparent; 156 | border-bottom-color: rgba(0, 0, 0, 0.2); 157 | content: ''; 158 | } 159 | 160 | .daterangepicker.openscenter:after { 161 | position: absolute; 162 | top: -6px; 163 | left: 0; 164 | right: 0; 165 | width: 0; 166 | margin-left: auto; 167 | margin-right: auto; 168 | display: inline-block; 169 | border-right: 6px solid transparent; 170 | border-bottom: 6px solid #fff; 171 | border-left: 6px solid transparent; 172 | content: ''; 173 | } 174 | 175 | .daterangepicker.opensright:before { 176 | position: absolute; 177 | top: -7px; 178 | left: 9px; 179 | display: inline-block; 180 | border-right: 7px solid transparent; 181 | border-bottom: 7px solid #ccc; 182 | border-left: 7px solid transparent; 183 | border-bottom-color: rgba(0, 0, 0, 0.2); 184 | content: ''; 185 | } 186 | 187 | .daterangepicker.opensright:after { 188 | position: absolute; 189 | top: -6px; 190 | left: 10px; 191 | display: inline-block; 192 | border-right: 6px solid transparent; 193 | border-bottom: 6px solid #fff; 194 | border-left: 6px solid transparent; 195 | content: ''; 196 | } 197 | 198 | .daterangepicker table { 199 | width: 100%; 200 | margin: 0; 201 | } 202 | 203 | .daterangepicker td, .daterangepicker th { 204 | text-align: center; 205 | width: 20px; 206 | height: 20px; 207 | -webkit-border-radius: 4px; 208 | -moz-border-radius: 4px; 209 | border-radius: 4px; 210 | cursor: pointer; 211 | white-space: nowrap; 212 | } 213 | 214 | .daterangepicker td.off { 215 | color: #999; 216 | } 217 | 218 | .daterangepicker td.disabled, .daterangepicker option.disabled { 219 | color: #999; 220 | } 221 | 222 | .daterangepicker td.available:hover, .daterangepicker th.available:hover { 223 | background: #eee; 224 | } 225 | 226 | .daterangepicker td.in-range { 227 | background: #ebf4f8; 228 | -webkit-border-radius: 0; 229 | -moz-border-radius: 0; 230 | border-radius: 0; 231 | } 232 | 233 | .daterangepicker td.active, .daterangepicker td.active:hover { 234 | background-color: #006dcc; 235 | background-image: -moz-linear-gradient(top, #0088cc, #0044cc); 236 | background-image: -ms-linear-gradient(top, #0088cc, #0044cc); 237 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); 238 | background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); 239 | background-image: -o-linear-gradient(top, #0088cc, #0044cc); 240 | background-image: linear-gradient(top, #0088cc, #0044cc); 241 | background-repeat: repeat-x; 242 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); 243 | border-color: #0044cc #0044cc #002a80; 244 | border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); 245 | filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); 246 | color: #fff; 247 | text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); 248 | } 249 | 250 | .daterangepicker td.week, .daterangepicker th.week { 251 | font-size: 80%; 252 | color: #ccc; 253 | } 254 | 255 | .daterangepicker select.monthselect, .daterangepicker select.yearselect { 256 | font-size: 12px; 257 | padding: 1px; 258 | height: auto; 259 | margin: 0; 260 | cursor: default; 261 | } 262 | 263 | .daterangepicker select.monthselect { 264 | margin-right: 2%; 265 | width: 56%; 266 | } 267 | 268 | .daterangepicker select.yearselect { 269 | width: 40%; 270 | } 271 | 272 | .daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.ampmselect { 273 | width: 60px; 274 | margin-bottom: 0; 275 | } 276 | 277 | .daterangepicker_start_input { 278 | float: left; 279 | } 280 | 281 | .daterangepicker_end_input { 282 | float: left; 283 | padding-left: 11px 284 | } 285 | 286 | .daterangepicker th.month { 287 | width: auto; 288 | } 289 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/laravel_google_analytics/e1ab3e7aa78d12f7525925b736304c18a84fff84/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | /* 10 | |-------------------------------------------------------------------------- 11 | | Register The Auto Loader 12 | |-------------------------------------------------------------------------- 13 | | 14 | | Composer provides a convenient, automatically generated class loader 15 | | for our application. We just need to utilize it! We'll require it 16 | | into the script here so that we do not have to worry about the 17 | | loading of any our classes "manually". Feels great to relax. 18 | | 19 | */ 20 | 21 | require __DIR__.'/../bootstrap/autoload.php'; 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Turn On The Lights 26 | |-------------------------------------------------------------------------- 27 | | 28 | | We need to illuminate PHP development, so let's turn on the lights. 29 | | This bootstraps the framework and gets it ready for use, then it 30 | | will load up this application so that we can run it and send 31 | | the responses back to the browser and delight these users. 32 | | 33 | */ 34 | 35 | $app = require_once __DIR__.'/../bootstrap/start.php'; 36 | 37 | /* 38 | |-------------------------------------------------------------------------- 39 | | Run The Application 40 | |-------------------------------------------------------------------------- 41 | | 42 | | Once we have the application, we can simply call the run method, 43 | | which will execute the request and send the response back to 44 | | the client's browser allowing them to enjoy the creative 45 | | and wonderful application we have whipped up for them. 46 | | 47 | */ 48 | 49 | $app->run(); 50 | -------------------------------------------------------------------------------- /public/js/daterangepicker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @version: 1.3.14 3 | * @author: Dan Grossman http://www.dangrossman.info/ 4 | * @date: 2014-10-17 5 | * @copyright: Copyright (c) 2012-2014 Dan Grossman. All rights reserved. 6 | * @license: Licensed under Apache License v2.0. See http://www.apache.org/licenses/LICENSE-2.0 7 | * @website: http://www.improvely.com/ 8 | */ 9 | 10 | (function(root, factory) { 11 | 12 | if (typeof define === 'function' && define.amd) { 13 | define(['moment', 'jquery', 'exports'], function(momentjs, $, exports) { 14 | root.daterangepicker = factory(root, exports, momentjs, $); 15 | }); 16 | 17 | } else if (typeof exports !== 'undefined') { 18 | var momentjs = require('moment'); 19 | var jQuery; 20 | try { 21 | jQuery = require('jquery'); 22 | } catch (err) { 23 | jQuery = window.jQuery; 24 | if (!jQuery) throw new Error('jQuery dependency not found'); 25 | } 26 | 27 | factory(root, exports, momentjs, jQuery); 28 | 29 | // Finally, as a browser global. 30 | } else { 31 | root.daterangepicker = factory(root, {}, root.moment, (root.jQuery || root.Zepto || root.ender || root.$)); 32 | } 33 | 34 | }(this, function(root, daterangepicker, moment, $) { 35 | 36 | var DateRangePicker = function (element, options, cb) { 37 | 38 | // by default, the daterangepicker element is placed at the bottom of HTML body 39 | this.parentEl = 'body'; 40 | 41 | //element that triggered the date range picker 42 | this.element = $(element); 43 | 44 | //tracks visible state 45 | this.isShowing = false; 46 | 47 | //create the picker HTML object 48 | var DRPTemplate = ''; 66 | 67 | //custom options 68 | if (typeof options !== 'object' || options === null) 69 | options = {}; 70 | 71 | this.parentEl = (typeof options === 'object' && options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl); 72 | this.container = $(DRPTemplate).appendTo(this.parentEl); 73 | 74 | this.setOptions(options, cb); 75 | 76 | //apply CSS classes and labels to buttons 77 | var c = this.container; 78 | $.each(this.buttonClasses, function (idx, val) { 79 | c.find('button').addClass(val); 80 | }); 81 | this.container.find('.daterangepicker_start_input label').html(this.locale.fromLabel); 82 | this.container.find('.daterangepicker_end_input label').html(this.locale.toLabel); 83 | if (this.applyClass.length) 84 | this.container.find('.applyBtn').addClass(this.applyClass); 85 | if (this.cancelClass.length) 86 | this.container.find('.cancelBtn').addClass(this.cancelClass); 87 | this.container.find('.applyBtn').html(this.locale.applyLabel); 88 | this.container.find('.cancelBtn').html(this.locale.cancelLabel); 89 | 90 | //event listeners 91 | 92 | this.container.find('.calendar') 93 | .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this)) 94 | .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this)) 95 | .on('click.daterangepicker', 'td.available', $.proxy(this.clickDate, this)) 96 | .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this)) 97 | .on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this)) 98 | .on('change.daterangepicker', 'select.yearselect', $.proxy(this.updateMonthYear, this)) 99 | .on('change.daterangepicker', 'select.monthselect', $.proxy(this.updateMonthYear, this)) 100 | .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.ampmselect', $.proxy(this.updateTime, this)); 101 | 102 | this.container.find('.ranges') 103 | .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this)) 104 | .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this)) 105 | .on('click.daterangepicker', '.daterangepicker_start_input,.daterangepicker_end_input', $.proxy(this.showCalendars, this)) 106 | .on('change.daterangepicker', '.daterangepicker_start_input,.daterangepicker_end_input', $.proxy(this.inputsChanged, this)) 107 | .on('keydown.daterangepicker', '.daterangepicker_start_input,.daterangepicker_end_input', $.proxy(this.inputsKeydown, this)) 108 | .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this)) 109 | .on('mouseenter.daterangepicker', 'li', $.proxy(this.enterRange, this)) 110 | .on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this)); 111 | 112 | if (this.element.is('input')) { 113 | this.element.on({ 114 | 'click.daterangepicker': $.proxy(this.show, this), 115 | 'focus.daterangepicker': $.proxy(this.show, this), 116 | 'keyup.daterangepicker': $.proxy(this.updateFromControl, this) 117 | }); 118 | } else { 119 | this.element.on('click.daterangepicker', $.proxy(this.toggle, this)); 120 | } 121 | 122 | }; 123 | 124 | DateRangePicker.prototype = { 125 | 126 | constructor: DateRangePicker, 127 | 128 | setOptions: function(options, callback) { 129 | 130 | this.startDate = moment().startOf('day'); 131 | this.endDate = moment().endOf('day'); 132 | this.minDate = false; 133 | this.maxDate = false; 134 | this.dateLimit = false; 135 | 136 | this.showDropdowns = false; 137 | this.showWeekNumbers = false; 138 | this.timePicker = false; 139 | this.timePickerIncrement = 30; 140 | this.timePicker12Hour = true; 141 | this.singleDatePicker = false; 142 | this.ranges = {}; 143 | 144 | this.opens = 'right'; 145 | if (this.element.hasClass('pull-right')) 146 | this.opens = 'left'; 147 | 148 | this.buttonClasses = ['btn', 'btn-small btn-sm']; 149 | this.applyClass = 'btn-success'; 150 | this.cancelClass = 'btn-default'; 151 | 152 | this.format = 'MM/DD/YYYY'; 153 | this.separator = ' - '; 154 | 155 | this.locale = { 156 | applyLabel: 'Apply', 157 | cancelLabel: 'Cancel', 158 | fromLabel: 'From', 159 | toLabel: 'To', 160 | weekLabel: 'W', 161 | customRangeLabel: 'Custom Range', 162 | daysOfWeek: moment.weekdaysMin(), 163 | monthNames: moment.monthsShort(), 164 | firstDay: moment.localeData()._week.dow 165 | }; 166 | 167 | this.cb = function () { }; 168 | 169 | if (typeof options.format === 'string') 170 | this.format = options.format; 171 | 172 | if (typeof options.separator === 'string') 173 | this.separator = options.separator; 174 | 175 | if (typeof options.startDate === 'string') 176 | this.startDate = moment(options.startDate, this.format); 177 | 178 | if (typeof options.endDate === 'string') 179 | this.endDate = moment(options.endDate, this.format); 180 | 181 | if (typeof options.minDate === 'string') 182 | this.minDate = moment(options.minDate, this.format); 183 | 184 | if (typeof options.maxDate === 'string') 185 | this.maxDate = moment(options.maxDate, this.format); 186 | 187 | if (typeof options.startDate === 'object') 188 | this.startDate = moment(options.startDate); 189 | 190 | if (typeof options.endDate === 'object') 191 | this.endDate = moment(options.endDate); 192 | 193 | if (typeof options.minDate === 'object') 194 | this.minDate = moment(options.minDate); 195 | 196 | if (typeof options.maxDate === 'object') 197 | this.maxDate = moment(options.maxDate); 198 | 199 | if (typeof options.applyClass === 'string') 200 | this.applyClass = options.applyClass; 201 | 202 | if (typeof options.cancelClass === 'string') 203 | this.cancelClass = options.cancelClass; 204 | 205 | if (typeof options.dateLimit === 'object') 206 | this.dateLimit = options.dateLimit; 207 | 208 | if (typeof options.locale === 'object') { 209 | 210 | if (typeof options.locale.daysOfWeek === 'object') { 211 | // Create a copy of daysOfWeek to avoid modification of original 212 | // options object for reusability in multiple daterangepicker instances 213 | this.locale.daysOfWeek = options.locale.daysOfWeek.slice(); 214 | } 215 | 216 | if (typeof options.locale.monthNames === 'object') { 217 | this.locale.monthNames = options.locale.monthNames.slice(); 218 | } 219 | 220 | if (typeof options.locale.firstDay === 'number') { 221 | this.locale.firstDay = options.locale.firstDay; 222 | } 223 | 224 | if (typeof options.locale.applyLabel === 'string') { 225 | this.locale.applyLabel = options.locale.applyLabel; 226 | } 227 | 228 | if (typeof options.locale.cancelLabel === 'string') { 229 | this.locale.cancelLabel = options.locale.cancelLabel; 230 | } 231 | 232 | if (typeof options.locale.fromLabel === 'string') { 233 | this.locale.fromLabel = options.locale.fromLabel; 234 | } 235 | 236 | if (typeof options.locale.toLabel === 'string') { 237 | this.locale.toLabel = options.locale.toLabel; 238 | } 239 | 240 | if (typeof options.locale.weekLabel === 'string') { 241 | this.locale.weekLabel = options.locale.weekLabel; 242 | } 243 | 244 | if (typeof options.locale.customRangeLabel === 'string') { 245 | this.locale.customRangeLabel = options.locale.customRangeLabel; 246 | } 247 | } 248 | 249 | if (typeof options.opens === 'string') 250 | this.opens = options.opens; 251 | 252 | if (typeof options.showWeekNumbers === 'boolean') { 253 | this.showWeekNumbers = options.showWeekNumbers; 254 | } 255 | 256 | if (typeof options.buttonClasses === 'string') { 257 | this.buttonClasses = [options.buttonClasses]; 258 | } 259 | 260 | if (typeof options.buttonClasses === 'object') { 261 | this.buttonClasses = options.buttonClasses; 262 | } 263 | 264 | if (typeof options.showDropdowns === 'boolean') { 265 | this.showDropdowns = options.showDropdowns; 266 | } 267 | 268 | if (typeof options.singleDatePicker === 'boolean') { 269 | this.singleDatePicker = options.singleDatePicker; 270 | if (this.singleDatePicker) { 271 | this.endDate = this.startDate.clone(); 272 | } 273 | } 274 | 275 | if (typeof options.timePicker === 'boolean') { 276 | this.timePicker = options.timePicker; 277 | } 278 | 279 | if (typeof options.timePickerIncrement === 'number') { 280 | this.timePickerIncrement = options.timePickerIncrement; 281 | } 282 | 283 | if (typeof options.timePicker12Hour === 'boolean') { 284 | this.timePicker12Hour = options.timePicker12Hour; 285 | } 286 | 287 | // update day names order to firstDay 288 | if (this.locale.firstDay != 0) { 289 | var iterator = this.locale.firstDay; 290 | while (iterator > 0) { 291 | this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()); 292 | iterator--; 293 | } 294 | } 295 | 296 | var start, end, range; 297 | 298 | //if no start/end dates set, check if an input element contains initial values 299 | if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') { 300 | if ($(this.element).is('input[type=text]')) { 301 | var val = $(this.element).val(); 302 | var split = val.split(this.separator); 303 | start = end = null; 304 | if (split.length == 2) { 305 | start = moment(split[0], this.format); 306 | end = moment(split[1], this.format); 307 | } else if (this.singleDatePicker) { 308 | start = moment(val, this.format); 309 | end = moment(val, this.format); 310 | } 311 | if (start !== null && end !== null) { 312 | this.startDate = start; 313 | this.endDate = end; 314 | } 315 | } 316 | } 317 | 318 | if (typeof options.ranges === 'object') { 319 | for (range in options.ranges) { 320 | 321 | start = moment(options.ranges[range][0]); 322 | end = moment(options.ranges[range][1]); 323 | 324 | // If we have a min/max date set, bound this range 325 | // to it, but only if it would otherwise fall 326 | // outside of the min/max. 327 | if (this.minDate && start.isBefore(this.minDate)) 328 | start = moment(this.minDate); 329 | 330 | if (this.maxDate && end.isAfter(this.maxDate)) 331 | end = moment(this.maxDate); 332 | 333 | // If the end of the range is before the minimum (if min is set) OR 334 | // the start of the range is after the max (also if set) don't display this 335 | // range option. 336 | if ((this.minDate && end.isBefore(this.minDate)) || (this.maxDate && start.isAfter(this.maxDate))) { 337 | continue; 338 | } 339 | 340 | this.ranges[range] = [start, end]; 341 | } 342 | 343 | var list = ''; 349 | this.container.find('.ranges ul').remove(); 350 | this.container.find('.ranges').prepend(list); 351 | } 352 | 353 | if (typeof callback === 'function') { 354 | this.cb = callback; 355 | } 356 | 357 | if (!this.timePicker) { 358 | this.startDate = this.startDate.startOf('day'); 359 | this.endDate = this.endDate.endOf('day'); 360 | } 361 | 362 | if (this.singleDatePicker) { 363 | this.opens = 'right'; 364 | this.container.addClass('single'); 365 | this.container.find('.calendar.right').show(); 366 | this.container.find('.calendar.left').hide(); 367 | if (!this.timePicker) { 368 | this.container.find('.ranges').hide(); 369 | } else { 370 | this.container.find('.ranges .daterangepicker_start_input, .ranges .daterangepicker_end_input').hide(); 371 | } 372 | if (!this.container.find('.calendar.right').hasClass('single')) 373 | this.container.find('.calendar.right').addClass('single'); 374 | } else { 375 | this.container.removeClass('single'); 376 | this.container.find('.calendar.right').removeClass('single'); 377 | this.container.find('.ranges').show(); 378 | } 379 | 380 | this.oldStartDate = this.startDate.clone(); 381 | this.oldEndDate = this.endDate.clone(); 382 | this.oldChosenLabel = this.chosenLabel; 383 | 384 | this.leftCalendar = { 385 | month: moment([this.startDate.year(), this.startDate.month(), 1, this.startDate.hour(), this.startDate.minute()]), 386 | calendar: [] 387 | }; 388 | 389 | this.rightCalendar = { 390 | month: moment([this.endDate.year(), this.endDate.month(), 1, this.endDate.hour(), this.endDate.minute()]), 391 | calendar: [] 392 | }; 393 | 394 | if (this.opens == 'right' || this.opens == 'center') { 395 | //swap calendar positions 396 | var left = this.container.find('.calendar.left'); 397 | var right = this.container.find('.calendar.right'); 398 | 399 | if (right.hasClass('single')) { 400 | right.removeClass('single'); 401 | left.addClass('single'); 402 | } 403 | 404 | left.removeClass('left').addClass('right'); 405 | right.removeClass('right').addClass('left'); 406 | 407 | if (this.singleDatePicker) { 408 | left.show(); 409 | right.hide(); 410 | } 411 | } 412 | 413 | if (typeof options.ranges === 'undefined' && !this.singleDatePicker) { 414 | this.container.addClass('show-calendar'); 415 | } 416 | 417 | this.container.addClass('opens' + this.opens); 418 | 419 | this.updateView(); 420 | this.updateCalendars(); 421 | 422 | }, 423 | 424 | setStartDate: function(startDate) { 425 | if (typeof startDate === 'string') 426 | this.startDate = moment(startDate, this.format); 427 | 428 | if (typeof startDate === 'object') 429 | this.startDate = moment(startDate); 430 | 431 | if (!this.timePicker) 432 | this.startDate = this.startDate.startOf('day'); 433 | 434 | this.oldStartDate = this.startDate.clone(); 435 | 436 | this.updateView(); 437 | this.updateCalendars(); 438 | this.updateInputText(); 439 | }, 440 | 441 | setEndDate: function(endDate) { 442 | if (typeof endDate === 'string') 443 | this.endDate = moment(endDate, this.format); 444 | 445 | if (typeof endDate === 'object') 446 | this.endDate = moment(endDate); 447 | 448 | if (!this.timePicker) 449 | this.endDate = this.endDate.endOf('day'); 450 | 451 | this.oldEndDate = this.endDate.clone(); 452 | 453 | this.updateView(); 454 | this.updateCalendars(); 455 | this.updateInputText(); 456 | }, 457 | 458 | updateView: function () { 459 | this.leftCalendar.month.month(this.startDate.month()).year(this.startDate.year()).hour(this.startDate.hour()).minute(this.startDate.minute()); 460 | this.rightCalendar.month.month(this.endDate.month()).year(this.endDate.year()).hour(this.endDate.hour()).minute(this.endDate.minute()); 461 | this.updateFormInputs(); 462 | }, 463 | 464 | updateFormInputs: function () { 465 | this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.format)); 466 | this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.format)); 467 | 468 | if (this.startDate.isSame(this.endDate) || this.startDate.isBefore(this.endDate)) { 469 | this.container.find('button.applyBtn').removeAttr('disabled'); 470 | } else { 471 | this.container.find('button.applyBtn').attr('disabled', 'disabled'); 472 | } 473 | }, 474 | 475 | updateFromControl: function () { 476 | if (!this.element.is('input')) return; 477 | if (!this.element.val().length) return; 478 | 479 | var dateString = this.element.val().split(this.separator), 480 | start = null, 481 | end = null; 482 | 483 | if(dateString.length === 2) { 484 | start = moment(dateString[0], this.format); 485 | end = moment(dateString[1], this.format); 486 | } 487 | 488 | if (this.singleDatePicker || start === null || end === null) { 489 | start = moment(this.element.val(), this.format); 490 | end = start; 491 | } 492 | 493 | if (end.isBefore(start)) return; 494 | 495 | this.oldStartDate = this.startDate.clone(); 496 | this.oldEndDate = this.endDate.clone(); 497 | 498 | this.startDate = start; 499 | this.endDate = end; 500 | 501 | if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate)) 502 | this.notify(); 503 | 504 | this.updateCalendars(); 505 | }, 506 | 507 | notify: function () { 508 | this.updateView(); 509 | this.cb(this.startDate, this.endDate, this.chosenLabel); 510 | }, 511 | 512 | move: function () { 513 | var parentOffset = { top: 0, left: 0 }; 514 | var parentRightEdge = $(window).width(); 515 | if (!this.parentEl.is('body')) { 516 | parentOffset = { 517 | top: this.parentEl.offset().top - this.parentEl.scrollTop(), 518 | left: this.parentEl.offset().left - this.parentEl.scrollLeft() 519 | }; 520 | parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left; 521 | } 522 | 523 | if (this.opens == 'left') { 524 | this.container.css({ 525 | top: this.element.offset().top + this.element.outerHeight() - parentOffset.top, 526 | right: parentRightEdge - this.element.offset().left - this.element.outerWidth(), 527 | left: 'auto' 528 | }); 529 | if (this.container.offset().left < 0) { 530 | this.container.css({ 531 | right: 'auto', 532 | left: 9 533 | }); 534 | } 535 | } else if (this.opens == 'center') { 536 | this.container.css({ 537 | top: this.element.offset().top + this.element.outerHeight() - parentOffset.top, 538 | left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2 539 | - this.container.outerWidth() / 2, 540 | right: 'auto' 541 | }); 542 | if (this.container.offset().left < 0) { 543 | this.container.css({ 544 | right: 'auto', 545 | left: 9 546 | }); 547 | } 548 | } else { 549 | this.container.css({ 550 | top: this.element.offset().top + this.element.outerHeight() - parentOffset.top, 551 | left: this.element.offset().left - parentOffset.left, 552 | right: 'auto' 553 | }); 554 | if (this.container.offset().left + this.container.outerWidth() > $(window).width()) { 555 | this.container.css({ 556 | left: 'auto', 557 | right: 0 558 | }); 559 | } 560 | } 561 | }, 562 | 563 | toggle: function (e) { 564 | if (this.element.hasClass('active')) { 565 | this.hide(); 566 | } else { 567 | this.show(); 568 | } 569 | }, 570 | 571 | show: function (e) { 572 | if (this.isShowing) return; 573 | 574 | this.element.addClass('active'); 575 | this.container.show(); 576 | this.move(); 577 | 578 | // Create a click proxy that is private to this instance of datepicker, for unbinding 579 | this._outsideClickProxy = $.proxy(function (e) { this.outsideClick(e); }, this); 580 | // Bind global datepicker mousedown for hiding and 581 | $(document) 582 | .on('mousedown.daterangepicker', this._outsideClickProxy) 583 | // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them 584 | .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy) 585 | // and also close when focus changes to outside the picker (eg. tabbing between controls) 586 | .on('focusin.daterangepicker', this._outsideClickProxy); 587 | 588 | this.isShowing = true; 589 | this.element.trigger('show.daterangepicker', this); 590 | }, 591 | 592 | outsideClick: function (e) { 593 | var target = $(e.target); 594 | // if the page is clicked anywhere except within the daterangerpicker/button 595 | // itself then call this.hide() 596 | if ( 597 | target.closest(this.element).length || 598 | target.closest(this.container).length || 599 | target.closest('.calendar-date').length 600 | ) return; 601 | this.hide(); 602 | }, 603 | 604 | hide: function (e) { 605 | if (!this.isShowing) return; 606 | 607 | $(document) 608 | .off('mousedown.daterangepicker') 609 | .off('click.daterangepicker', '[data-toggle=dropdown]') 610 | .off('focusin.daterangepicker'); 611 | 612 | this.element.removeClass('active'); 613 | this.container.hide(); 614 | 615 | if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate)) 616 | this.notify(); 617 | 618 | this.oldStartDate = this.startDate.clone(); 619 | this.oldEndDate = this.endDate.clone(); 620 | 621 | this.isShowing = false; 622 | this.element.trigger('hide.daterangepicker', this); 623 | }, 624 | 625 | enterRange: function (e) { 626 | // mouse pointer has entered a range label 627 | var label = e.target.innerHTML; 628 | if (label == this.locale.customRangeLabel) { 629 | this.updateView(); 630 | } else { 631 | var dates = this.ranges[label]; 632 | this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.format)); 633 | this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.format)); 634 | } 635 | }, 636 | 637 | showCalendars: function() { 638 | this.container.addClass('show-calendar'); 639 | this.move(); 640 | this.element.trigger('showCalendar.daterangepicker', this); 641 | }, 642 | 643 | hideCalendars: function() { 644 | this.container.removeClass('show-calendar'); 645 | this.element.trigger('hideCalendar.daterangepicker', this); 646 | }, 647 | 648 | // when a date is typed into the start to end date textboxes 649 | inputsChanged: function (e) { 650 | var el = $(e.target); 651 | var date = moment(el.val(), this.format); 652 | if (!date.isValid()) return; 653 | 654 | var startDate, endDate; 655 | if (el.attr('name') === 'daterangepicker_start') { 656 | startDate = date; 657 | endDate = this.endDate; 658 | } else { 659 | startDate = this.startDate; 660 | endDate = date; 661 | } 662 | this.setCustomDates(startDate, endDate); 663 | }, 664 | 665 | inputsKeydown: function(e) { 666 | if (e.keyCode === 13) { 667 | this.inputsChanged(e); 668 | this.notify(); 669 | } 670 | }, 671 | 672 | updateInputText: function() { 673 | if (this.element.is('input') && !this.singleDatePicker) { 674 | this.element.val(this.startDate.format(this.format) + this.separator + this.endDate.format(this.format)); 675 | } else if (this.element.is('input')) { 676 | this.element.val(this.endDate.format(this.format)); 677 | } 678 | }, 679 | 680 | clickRange: function (e) { 681 | var label = e.target.innerHTML; 682 | this.chosenLabel = label; 683 | if (label == this.locale.customRangeLabel) { 684 | this.showCalendars(); 685 | } else { 686 | var dates = this.ranges[label]; 687 | 688 | this.startDate = dates[0]; 689 | this.endDate = dates[1]; 690 | 691 | if (!this.timePicker) { 692 | this.startDate.startOf('day'); 693 | this.endDate.endOf('day'); 694 | } 695 | 696 | this.leftCalendar.month.month(this.startDate.month()).year(this.startDate.year()).hour(this.startDate.hour()).minute(this.startDate.minute()); 697 | this.rightCalendar.month.month(this.endDate.month()).year(this.endDate.year()).hour(this.endDate.hour()).minute(this.endDate.minute()); 698 | this.updateCalendars(); 699 | 700 | this.updateInputText(); 701 | 702 | this.hideCalendars(); 703 | this.hide(); 704 | this.element.trigger('apply.daterangepicker', this); 705 | } 706 | }, 707 | 708 | clickPrev: function (e) { 709 | var cal = $(e.target).parents('.calendar'); 710 | if (cal.hasClass('left')) { 711 | this.leftCalendar.month.subtract(1, 'month'); 712 | } else { 713 | this.rightCalendar.month.subtract(1, 'month'); 714 | } 715 | this.updateCalendars(); 716 | }, 717 | 718 | clickNext: function (e) { 719 | var cal = $(e.target).parents('.calendar'); 720 | if (cal.hasClass('left')) { 721 | this.leftCalendar.month.add(1, 'month'); 722 | } else { 723 | this.rightCalendar.month.add(1, 'month'); 724 | } 725 | this.updateCalendars(); 726 | }, 727 | 728 | hoverDate: function (e) { 729 | var title = $(e.target).attr('data-title'); 730 | var row = title.substr(1, 1); 731 | var col = title.substr(3, 1); 732 | var cal = $(e.target).parents('.calendar'); 733 | 734 | if (cal.hasClass('left')) { 735 | this.container.find('input[name=daterangepicker_start]').val(this.leftCalendar.calendar[row][col].format(this.format)); 736 | } else { 737 | this.container.find('input[name=daterangepicker_end]').val(this.rightCalendar.calendar[row][col].format(this.format)); 738 | } 739 | }, 740 | 741 | setCustomDates: function(startDate, endDate) { 742 | this.chosenLabel = this.locale.customRangeLabel; 743 | if (startDate.isAfter(endDate)) { 744 | var difference = this.endDate.diff(this.startDate); 745 | endDate = moment(startDate).add(difference, 'ms'); 746 | } 747 | this.startDate = startDate; 748 | this.endDate = endDate; 749 | 750 | this.updateView(); 751 | this.updateCalendars(); 752 | }, 753 | 754 | clickDate: function (e) { 755 | var title = $(e.target).attr('data-title'); 756 | var row = title.substr(1, 1); 757 | var col = title.substr(3, 1); 758 | var cal = $(e.target).parents('.calendar'); 759 | 760 | var startDate, endDate; 761 | if (cal.hasClass('left')) { 762 | startDate = this.leftCalendar.calendar[row][col]; 763 | endDate = this.endDate; 764 | if (typeof this.dateLimit === 'object') { 765 | var maxDate = moment(startDate).add(this.dateLimit).startOf('day'); 766 | if (endDate.isAfter(maxDate)) { 767 | endDate = maxDate; 768 | } 769 | } 770 | } else { 771 | startDate = this.startDate; 772 | endDate = this.rightCalendar.calendar[row][col]; 773 | if (typeof this.dateLimit === 'object') { 774 | var minDate = moment(endDate).subtract(this.dateLimit).startOf('day'); 775 | if (startDate.isBefore(minDate)) { 776 | startDate = minDate; 777 | } 778 | } 779 | } 780 | 781 | if (this.singleDatePicker && cal.hasClass('left')) { 782 | endDate = startDate.clone(); 783 | } else if (this.singleDatePicker && cal.hasClass('right')) { 784 | startDate = endDate.clone(); 785 | } 786 | 787 | cal.find('td').removeClass('active'); 788 | 789 | $(e.target).addClass('active'); 790 | 791 | this.setCustomDates(startDate, endDate); 792 | 793 | if (!this.timePicker) 794 | endDate.endOf('day'); 795 | 796 | if (this.singleDatePicker && !this.timePicker) 797 | this.clickApply(); 798 | }, 799 | 800 | clickApply: function (e) { 801 | this.updateInputText(); 802 | this.hide(); 803 | this.element.trigger('apply.daterangepicker', this); 804 | }, 805 | 806 | clickCancel: function (e) { 807 | this.startDate = this.oldStartDate; 808 | this.endDate = this.oldEndDate; 809 | this.chosenLabel = this.oldChosenLabel; 810 | this.updateView(); 811 | this.updateCalendars(); 812 | this.hide(); 813 | this.element.trigger('cancel.daterangepicker', this); 814 | }, 815 | 816 | updateMonthYear: function (e) { 817 | var isLeft = $(e.target).closest('.calendar').hasClass('left'), 818 | leftOrRight = isLeft ? 'left' : 'right', 819 | cal = this.container.find('.calendar.'+leftOrRight); 820 | 821 | // Month must be Number for new moment versions 822 | var month = parseInt(cal.find('.monthselect').val(), 10); 823 | var year = cal.find('.yearselect').val(); 824 | 825 | this[leftOrRight+'Calendar'].month.month(month).year(year); 826 | this.updateCalendars(); 827 | }, 828 | 829 | updateTime: function(e) { 830 | 831 | var cal = $(e.target).closest('.calendar'), 832 | isLeft = cal.hasClass('left'); 833 | 834 | var hour = parseInt(cal.find('.hourselect').val(), 10); 835 | var minute = parseInt(cal.find('.minuteselect').val(), 10); 836 | 837 | if (this.timePicker12Hour) { 838 | var ampm = cal.find('.ampmselect').val(); 839 | if (ampm === 'PM' && hour < 12) 840 | hour += 12; 841 | if (ampm === 'AM' && hour === 12) 842 | hour = 0; 843 | } 844 | 845 | if (isLeft) { 846 | var start = this.startDate.clone(); 847 | start.hour(hour); 848 | start.minute(minute); 849 | this.startDate = start; 850 | this.leftCalendar.month.hour(hour).minute(minute); 851 | } else { 852 | var end = this.endDate.clone(); 853 | end.hour(hour); 854 | end.minute(minute); 855 | this.endDate = end; 856 | this.rightCalendar.month.hour(hour).minute(minute); 857 | } 858 | 859 | this.updateCalendars(); 860 | }, 861 | 862 | updateCalendars: function () { 863 | this.leftCalendar.calendar = this.buildCalendar(this.leftCalendar.month.month(), this.leftCalendar.month.year(), this.leftCalendar.month.hour(), this.leftCalendar.month.minute(), 'left'); 864 | this.rightCalendar.calendar = this.buildCalendar(this.rightCalendar.month.month(), this.rightCalendar.month.year(), this.rightCalendar.month.hour(), this.rightCalendar.month.minute(), 'right'); 865 | this.container.find('.calendar.left').empty().html(this.renderCalendar(this.leftCalendar.calendar, this.startDate, this.minDate, this.maxDate, 'left')); 866 | this.container.find('.calendar.right').empty().html(this.renderCalendar(this.rightCalendar.calendar, this.endDate, this.singleDatePicker ? this.minDate : this.startDate, this.maxDate, 'right')); 867 | 868 | this.container.find('.ranges li').removeClass('active'); 869 | var customRange = true; 870 | var i = 0; 871 | for (var range in this.ranges) { 872 | if (this.timePicker) { 873 | if (this.startDate.isSame(this.ranges[range][0]) && this.endDate.isSame(this.ranges[range][1])) { 874 | customRange = false; 875 | this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')') 876 | .addClass('active').html(); 877 | } 878 | } else { 879 | //ignore times when comparing dates if time picker is not enabled 880 | if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) { 881 | customRange = false; 882 | this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')') 883 | .addClass('active').html(); 884 | } 885 | } 886 | i++; 887 | } 888 | if (customRange) { 889 | this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html(); 890 | this.showCalendars(); 891 | } 892 | }, 893 | 894 | buildCalendar: function (month, year, hour, minute, side) { 895 | var daysInMonth = moment([year, month]).daysInMonth(); 896 | var firstDay = moment([year, month, 1]); 897 | var lastDay = moment([year, month, daysInMonth]); 898 | var lastMonth = moment(firstDay).subtract(1, 'month').month(); 899 | var lastYear = moment(firstDay).subtract(1, 'month').year(); 900 | 901 | var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth(); 902 | 903 | var dayOfWeek = firstDay.day(); 904 | 905 | var i; 906 | 907 | //initialize a 6 rows x 7 columns array for the calendar 908 | var calendar = []; 909 | calendar.firstDay = firstDay; 910 | calendar.lastDay = lastDay; 911 | 912 | for (i = 0; i < 6; i++) { 913 | calendar[i] = []; 914 | } 915 | 916 | //populate the calendar with date objects 917 | var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1; 918 | if (startDay > daysInLastMonth) 919 | startDay -= 7; 920 | 921 | if (dayOfWeek == this.locale.firstDay) 922 | startDay = daysInLastMonth - 6; 923 | 924 | var curDate = moment([lastYear, lastMonth, startDay, 12, minute]); 925 | var col, row; 926 | for (i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) { 927 | if (i > 0 && col % 7 === 0) { 928 | col = 0; 929 | row++; 930 | } 931 | calendar[row][col] = curDate.clone().hour(hour); 932 | curDate.hour(12); 933 | 934 | if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') { 935 | calendar[row][col] = this.minDate.clone(); 936 | } 937 | 938 | if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') { 939 | calendar[row][col] = this.maxDate.clone(); 940 | } 941 | 942 | } 943 | 944 | return calendar; 945 | }, 946 | 947 | renderDropdowns: function (selected, minDate, maxDate) { 948 | var currentMonth = selected.month(); 949 | var currentYear = selected.year(); 950 | var maxYear = (maxDate && maxDate.year()) || (currentYear + 5); 951 | var minYear = (minDate && minDate.year()) || (currentYear - 50); 952 | 953 | var monthHtml = '"; 965 | 966 | var yearHtml = ''; 975 | 976 | return monthHtml + yearHtml; 977 | }, 978 | 979 | renderCalendar: function (calendar, selected, minDate, maxDate, side) { 980 | 981 | var html = '
'; 982 | html += ''; 983 | html += ''; 984 | html += ''; 985 | 986 | // add empty cell for week number 987 | if (this.showWeekNumbers) 988 | html += ''; 989 | 990 | if (!minDate || minDate.isBefore(calendar.firstDay)) { 991 | html += ''; 992 | } else { 993 | html += ''; 994 | } 995 | 996 | var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY"); 997 | 998 | if (this.showDropdowns) { 999 | dateHtml = this.renderDropdowns(calendar[1][1], minDate, maxDate); 1000 | } 1001 | 1002 | html += ''; 1003 | if (!maxDate || maxDate.isAfter(calendar.lastDay)) { 1004 | html += ''; 1005 | } else { 1006 | html += ''; 1007 | } 1008 | 1009 | html += ''; 1010 | html += ''; 1011 | 1012 | // add week number label 1013 | if (this.showWeekNumbers) 1014 | html += ''; 1015 | 1016 | $.each(this.locale.daysOfWeek, function (index, dayOfWeek) { 1017 | html += ''; 1018 | }); 1019 | 1020 | html += ''; 1021 | html += ''; 1022 | html += ''; 1023 | 1024 | for (var row = 0; row < 6; row++) { 1025 | html += ''; 1026 | 1027 | // add week number 1028 | if (this.showWeekNumbers) 1029 | html += ''; 1030 | 1031 | for (var col = 0; col < 7; col++) { 1032 | var cname = 'available '; 1033 | cname += (calendar[row][col].month() == calendar[1][1].month()) ? '' : 'off'; 1034 | 1035 | if ((minDate && calendar[row][col].isBefore(minDate, 'day')) || (maxDate && calendar[row][col].isAfter(maxDate, 'day'))) { 1036 | cname = ' off disabled '; 1037 | } else if (calendar[row][col].format('YYYY-MM-DD') == selected.format('YYYY-MM-DD')) { 1038 | cname += ' active '; 1039 | if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD')) { 1040 | cname += ' start-date '; 1041 | } 1042 | if (calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD')) { 1043 | cname += ' end-date '; 1044 | } 1045 | } else if (calendar[row][col] >= this.startDate && calendar[row][col] <= this.endDate) { 1046 | cname += ' in-range '; 1047 | if (calendar[row][col].isSame(this.startDate)) { cname += ' start-date '; } 1048 | if (calendar[row][col].isSame(this.endDate)) { cname += ' end-date '; } 1049 | } 1050 | 1051 | var title = 'r' + row + 'c' + col; 1052 | html += ''; 1053 | } 1054 | html += ''; 1055 | } 1056 | 1057 | html += ''; 1058 | html += '
' + dateHtml + '
' + this.locale.weekLabel + '' + dayOfWeek + '
' + calendar[row][0].week() + '' + calendar[row][col].date() + '
'; 1059 | html += '
'; 1060 | 1061 | var i; 1062 | if (this.timePicker) { 1063 | 1064 | html += '
'; 1065 | html += ' : '; 1113 | 1114 | html += ' '; 1146 | 1147 | if (this.timePicker12Hour) { 1148 | html += ''; 1168 | } 1169 | 1170 | html += '
'; 1171 | 1172 | } 1173 | 1174 | return html; 1175 | 1176 | }, 1177 | 1178 | remove: function() { 1179 | 1180 | this.container.remove(); 1181 | this.element.off('.daterangepicker'); 1182 | this.element.removeData('daterangepicker'); 1183 | 1184 | } 1185 | 1186 | }; 1187 | 1188 | $.fn.daterangepicker = function (options, cb) { 1189 | this.each(function () { 1190 | var el = $(this); 1191 | if (el.data('daterangepicker')) 1192 | el.data('daterangepicker').remove(); 1193 | el.data('daterangepicker', new DateRangePicker(el, options, cb)); 1194 | }); 1195 | return this; 1196 | }; 1197 | 1198 | })); 1199 | -------------------------------------------------------------------------------- /public/packages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/laravel_google_analytics/e1ab3e7aa78d12f7525925b736304c18a84fff84/public/packages/.gitkeep -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | laravel_google_analytics 2 | ======================== 3 | 4 | Small demo for the "Using Google Analytics API" 5 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 |