22
33namespace koolreport \laravel ;
44
5-
6- use \koolreport \core \Utility ;
75use Config ;
6+ use \koolreport \core \Utility ;
87
98trait 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+ }
0 commit comments