Skip to content

Commit 3d6dc97

Browse files
committed
add tests
1 parent 8fa5c2c commit 3d6dc97

17 files changed

+798
-557
lines changed

config/lara_support.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
return [
3+
'cache' => [
4+
'time' => 2,
5+
],
6+
'security' => [
7+
'password' => [
8+
'cost' => 12
9+
]
10+
]
11+
];

src/Facades/LaraDB.php

Lines changed: 8 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,18 @@
11
<?php
22

3-
namespace LaraSupport;
3+
namespace LaraSupport\Facades;
44

5-
use Illuminate\Support\Facades\DB;
5+
use Illuminate\Support\Facades\Facade;
66

7-
class LaraDB
7+
class LaraDB extends Facade
88
{
99
/**
10-
* @return array
10+
* Get the registered name of the component.
11+
*
12+
* @return string
1113
*/
12-
public static function getTables()
14+
protected static function getFacadeAccessor()
1315
{
14-
$tablesInDb = DB::select('SHOW TABLES');
15-
$db = "Tables_in_".env('DB_DATABASE');
16-
$tables = [];
17-
18-
foreach($tablesInDb as $table){
19-
$tables[] = $table->{$db};
20-
}
21-
22-
return $tables;
23-
}
24-
25-
/**
26-
* @param $table
27-
* @return array
28-
*/
29-
public static function getColumnsFullInfo($table)
30-
{
31-
$columns = DB::select('show columns from ' . $table);
32-
$columnsInfo = [];
33-
34-
foreach ($columns as $column) {
35-
$columnsInfo[$column->Field] = [
36-
'type' => Str::before($column->Type, '('),
37-
'is_nullable' => $column->Null ? true : false,
38-
'default' => $column->Default,
39-
'extra' => $column->Extra,
40-
'unsigned' => str_contains($column->Type, 'unsigned') ? true : false,
41-
'full_info' => $column->Type,
42-
];
43-
if (Str::between($column->Type, '(', ')') != $column->Type) {
44-
$columnsInfo[$column->Field]['length'] = Str::between($column->Type, '(', ')');
45-
}
46-
}
47-
48-
return $columnsInfo;
16+
return 'lara-db';
4917
}
50-
51-
/**
52-
* @return array
53-
*/
54-
public static function getDBStructure()
55-
{
56-
$query = sprintf("SELECT * FROM information_schema.columns WHERE table_schema ='%s'", env('DB_DATABASE'));
57-
$dbStructures = DB::select($query);
58-
$tables = [];
59-
60-
foreach ($dbStructures as $dbStructure) {
61-
if ($dbStructure->DATA_TYPE == 'int') {
62-
}
63-
$tables[$dbStructure->TABLE_NAME][$dbStructure->COLUMN_NAME] = [
64-
'type' => $dbStructure->DATA_TYPE,
65-
'is_nullable' => $dbStructure->IS_NULLABLE == 'YES' ? true : false,
66-
'default' => $dbStructure->COLUMN_DEFAULT,
67-
'extra' => $dbStructure->EXTRA,
68-
'unsigned' => str_contains($dbStructure->COLUMN_TYPE, 'unsigned') ? true : false,
69-
'column_type' => $dbStructure->COLUMN_TYPE,
70-
];
71-
if ($dbStructure->CHARACTER_MAXIMUM_LENGTH) {
72-
$tables[$dbStructure->TABLE_NAME][$dbStructure->COLUMN_NAME]['length'] = $dbStructure->CHARACTER_MAXIMUM_LENGTH;
73-
}
74-
}
75-
76-
return $tables;
77-
}
78-
7918
}

src/Facades/LaraPassword.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace LaraSupport\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class LaraPassword extends Facade
8+
{
9+
/**
10+
* Get the registered name of the component.
11+
*
12+
* @return string
13+
*/
14+
protected static function getFacadeAccessor()
15+
{
16+
return 'lara-password';
17+
}
18+
}

src/Facades/LaraUtil.php

Lines changed: 0 additions & 159 deletions
This file was deleted.

0 commit comments

Comments
 (0)