-
Notifications
You must be signed in to change notification settings - Fork 3
/
Friendship.php
55 lines (48 loc) · 1.68 KB
/
Friendship.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace koolreport\laravel;
use Config;
use \koolreport\core\Utility;
trait Friendship
{
public function __constructFriendship()
{
$base_url = url("");
$base_url = str_replace("://", "--", $base_url);
if (strpos($base_url, "/") !== false) {
$base_url = substr($base_url, strpos($base_url, "/"));
} else {
$base_url = "";
}
//assets folder
$assets = Utility::get($this->reportSettings, "assets");
if ($assets == null) {
$public_path = str_replace("\\", "/", public_path());
if (!is_dir($public_path . "/koolreport_assets")) {
mkdir($public_path . "/koolreport_assets", 0755);
}
$assets = array(
"url" => $base_url . "/koolreport_assets",
"path" => $public_path . "/koolreport_assets",
);
$this->reportSettings["assets"] = $assets;
}
//DataSources
$dbSources = array();
$dbConfig = Config::get('database');
$defaultSource = Utility::get($dbConfig, "default");
if ($defaultSource) {
$dbSources[$defaultSource] = array(
"class" => LaravelDataSource::class,
"name" => $defaultSource,
);
}
foreach ($dbConfig["connections"] as $name => $config) {
$dbSources[$name] = array(
"class" => LaravelDataSource::class,
"name" => $name,
);
}
$dataSources = Utility::get($this->reportSettings, "dataSources", array());
$this->reportSettings["dataSources"] = array_merge($dbSources, $dataSources);
}
}