Skip to content

Commit 8e7d896

Browse files
committed
Detect secure connection to return correct url for assets.
1 parent 3431883 commit 8e7d896

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## Version 1.7.0 (new)
4+
5+
1. Detect secure connection to return correct url for assets.
6+
37
## Version 1.6.0
48

59
1. Change README

Friendship.php

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,48 @@
22

33
namespace koolreport\laravel;
44

5-
6-
use \koolreport\core\Utility;
75
use Config;
6+
use \koolreport\core\Utility;
87

98
trait Friendship
109
{
1110
public function __constructFriendship()
1211
{
12+
$isSecure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
13+
|| $_SERVER['SERVER_PORT'] == 443;
14+
1315
//assets folder
14-
$assets = Utility::get($this->reportSettings,"assets");
15-
if($assets==null)
16-
{
17-
$public_path = str_replace("\\","/",public_path());
18-
if(!is_dir($public_path."/koolreport_assets"))
19-
{
20-
mkdir($public_path."/koolreport_assets",0755);
16+
$assets = Utility::get($this->reportSettings, "assets");
17+
if ($assets == null) {
18+
$public_path = str_replace("\\", "/", public_path());
19+
if (!is_dir($public_path . "/koolreport_assets")) {
20+
mkdir($public_path . "/koolreport_assets", 0755);
2121
}
2222
$assets = array(
23-
"url"=>url("")."/koolreport_assets",
24-
"path"=>$public_path."/koolreport_assets",
23+
"url" => ($isSecure ? secure_url() : url("")) . "/koolreport_assets",
24+
"path" => $public_path . "/koolreport_assets",
2525
);
2626
$this->reportSettings["assets"] = $assets;
2727
}
2828

2929
//DataSources
3030
$dbSources = array();
3131
$dbConfig = Config::get('database');
32-
$defaultSource = Utility::get($dbConfig,"default");
33-
if($defaultSource)
34-
{
32+
$defaultSource = Utility::get($dbConfig, "default");
33+
if ($defaultSource) {
3534
$dbSources[$defaultSource] = array(
36-
"class"=>LaravelDataSource::class,
37-
"name"=>$defaultSource,
35+
"class" => LaravelDataSource::class,
36+
"name" => $defaultSource,
3837
);
3938
}
40-
foreach($dbConfig["connections"] as $name=>$config)
41-
{
39+
foreach ($dbConfig["connections"] as $name => $config) {
4240
$dbSources[$name] = array(
43-
"class"=>LaravelDataSource::class,
44-
"name"=>$name,
41+
"class" => LaravelDataSource::class,
42+
"name" => $name,
4543
);
4644
}
47-
$dataSources = Utility::get($this->reportSettings,"dataSources",array());
48-
$this->reportSettings["dataSources"] = array_merge($dbSources,$dataSources);
45+
$dataSources = Utility::get($this->reportSettings, "dataSources", array());
46+
$this->reportSettings["dataSources"] = array_merge($dbSources, $dataSources);
4947

5048
}
51-
}
49+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "koolreport/laravel",
3-
"version":"1.6.0",
3+
"version":"1.7.0",
44
"description": "Allow to use KoolReport seamlessly in Laravel",
55
"keywords": ["PHP","Reporting Tools","Data Report","laravel","KooLReport Laravel","Laravel Report","laravel reporting","laravel reporting tool"],
66
"homepage": "https://www.koolreport.com",

0 commit comments

Comments
 (0)