File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Bekwoh \LaravelDbDoc \Data ;
4
4
5
+ use Illuminate \Support \Collection ;
6
+
5
7
class Schema
6
8
{
9
+ protected Collection $ collections ;
10
+
7
11
public function __construct (protected $ tables , protected $ schema )
8
12
{
9
13
}
@@ -18,7 +22,7 @@ public function getData()
18
22
$ tables = $ this ->tables ;
19
23
$ schema = $ this ->schema ;
20
24
21
- $ this ->collections = [] ;
25
+ $ this ->collections = collect () ;
22
26
foreach ($ tables as $ table ) {
23
27
$ columns = $ schema ->listTableColumns ($ table );
24
28
$ foreignKeys = collect ($ schema ->listTableForeignKeys ($ table ))->keyBy (function ($ foreignColumn ) {
@@ -45,7 +49,7 @@ public function getData()
45
49
}
46
50
}
47
51
48
- return $ this ->collections ;
52
+ return $ this ->collections -> toArray () ;
49
53
}
50
54
51
55
private function determineUnsigned ($ column )
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public static function routes()
32
32
}
33
33
}
34
34
35
- public function content ($ format )
35
+ public static function content ($ format )
36
36
{
37
37
throw_if (! in_array ($ format , ['json ' , 'markdown ' ]));
38
38
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ class Processor
10
10
{
11
11
protected array $ data ;
12
12
13
+ protected $ schema ;
14
+ protected $ tables ;
15
+ protected $ connection ;
16
+ protected $ database_connection ;
17
+
13
18
protected string $ presenter ;
14
19
15
20
public function __construct ()
@@ -43,15 +48,15 @@ public function render()
43
48
->write ();
44
49
}
45
50
46
- public function connect (string $ connection , string $ format ): self
51
+ public function connect (string $ database_connection , string $ format ): self
47
52
{
48
- $ this ->database_connection = $ connection ;
53
+ $ this ->database_connection = $ database_connection ;
49
54
$ this ->presenter = config ('db-doc.presentations. ' .$ format .'.class ' );
50
55
51
56
throw_if (! class_exists ($ this ->presenter ), 'RuntimeException ' , "$ this ->presenter not exists. " );
52
57
53
58
$ this ->connection = DB ::connection ($ this ->database_connection )->getDoctrineConnection ();
54
- $ this ->schema = $ this ->connection ->getSchemaManager ();
59
+ $ this ->schema = $ this ->connection ->createSchemaManager ();
55
60
$ this ->tables = $ this ->schema ->listTableNames ();
56
61
57
62
return $ this ;
You can’t perform that action at this time.
0 commit comments