1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Cortex\Console\DataTables\Adminarea; |
6
|
|
|
|
7
|
|
|
use Illuminate\Routing\Route; |
8
|
|
|
use Cortex\Foundation\DataTables\AbstractDataTable; |
9
|
|
|
use Illuminate\Support\Facades\Route as RouteFacade; |
10
|
|
|
|
11
|
|
|
class RoutesDataTable extends AbstractDataTable |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Get the query object to be processed by dataTables. |
15
|
|
|
* |
16
|
|
|
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection |
17
|
|
|
*/ |
18
|
|
|
public function query() |
19
|
|
|
{ |
20
|
|
|
$routes = collect(RouteFacade::getRoutes()); |
21
|
|
|
|
22
|
|
|
$routes->transform(function (Route $route, $key) { |
|
|
|
|
23
|
|
|
return [ |
24
|
|
|
'domain' => (string) $route->getDomain(), |
25
|
|
|
'uri' => (string) $route->uri() === '/' ? '/' : '/'.$route->uri(), |
26
|
|
|
'name' => (string) $route->getName(), |
27
|
|
|
'methods' => (string) implode(', ', $route->methods()), |
28
|
|
|
'action' => (string) $route->getActionName(), |
29
|
|
|
'middleware' => (string) implode(', ', $route->gatherMiddleware()), |
30
|
|
|
]; |
31
|
|
|
}); |
32
|
|
|
|
33
|
|
|
return $routes; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Get columns. |
38
|
|
|
* |
39
|
|
|
* @return array |
40
|
|
|
*/ |
41
|
|
|
protected function getColumns(): array |
42
|
|
|
{ |
43
|
|
|
return [ |
44
|
|
|
'domain' => ['title' => trans('cortex/console::common.domain')], |
45
|
|
|
'uri' => ['title' => trans('cortex/console::common.uri')], |
46
|
|
|
'name' => ['title' => trans('cortex/console::common.name')], |
47
|
|
|
'methods' => ['title' => trans('cortex/console::common.methods')], |
48
|
|
|
'action' => ['title' => trans('cortex/console::common.action')], |
49
|
|
|
'middleware' => ['title' => trans('cortex/console::common.middleware')], |
50
|
|
|
]; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get filename for export. |
55
|
|
|
* |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
|
protected function filename(): string |
59
|
|
|
{ |
60
|
|
|
return 'routes-export-'.date('Y-m-d').'-'.time(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Get default builder parameters. |
65
|
|
|
* |
66
|
|
|
* @return array |
67
|
|
|
*/ |
68
|
|
|
protected function getBuilderParameters(): array |
69
|
|
|
{ |
70
|
|
|
return [ |
71
|
|
|
'keys' => true, |
72
|
|
|
'retrieve' => true, |
73
|
|
|
'autoWidth' => false, |
74
|
|
|
'dom' => "<'row'<'col-sm-6'B><'col-sm-6'f>> <'row'r><'row'<'col-sm-12't>> <'row'<'col-sm-5'i><'col-sm-7'p>>", |
|
|
|
|
75
|
|
|
'buttons' => [ |
76
|
|
|
'print', 'reset', 'reload', 'export', |
77
|
|
|
['extend' => 'colvis', 'text' => '<i class="fa fa-columns"></i> '.trans('cortex/foundation::common.columns').' <span class="caret"/>'], |
|
|
|
|
78
|
|
|
['extend' => 'pageLength', 'text' => '<i class="fa fa-list-ol"></i> '.trans('cortex/foundation::common.limit').' <span class="caret"/>'], |
|
|
|
|
79
|
|
|
], |
80
|
|
|
]; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.