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
|
|
|
* Display ajax response. |
15
|
|
|
* |
16
|
|
|
* @return \Illuminate\Http\JsonResponse |
17
|
|
|
*/ |
18
|
|
|
public function ajax() |
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 datatables()->collection($routes) |
|
|
|
|
34
|
|
|
->make(true); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Get columns. |
39
|
|
|
* |
40
|
|
|
* @return array |
|
|
|
|
41
|
|
|
*/ |
42
|
|
|
protected function getColumns() |
43
|
|
|
{ |
44
|
|
|
return [ |
45
|
|
|
'domain' => ['title' => trans('cortex/console::common.domain')], |
46
|
|
|
'uri' => ['title' => trans('cortex/console::common.uri')], |
47
|
|
|
'name' => ['title' => trans('cortex/console::common.name')], |
48
|
|
|
'methods' => ['title' => trans('cortex/console::common.methods')], |
49
|
|
|
'action' => ['title' => trans('cortex/console::common.action')], |
50
|
|
|
'middleware' => ['title' => trans('cortex/console::common.middleware')], |
51
|
|
|
]; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Get filename for export. |
56
|
|
|
* |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
protected function filename() |
60
|
|
|
{ |
61
|
|
|
return 'routes-export-'.date('Y-m-d').'-'.time(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Get default builder parameters. |
66
|
|
|
* |
67
|
|
|
* @return array |
|
|
|
|
68
|
|
|
*/ |
69
|
|
|
protected function getBuilderParameters() |
70
|
|
|
{ |
71
|
|
|
return [ |
72
|
|
|
'keys' => 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.