@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Woo\GridView\Columns; |
4 | 4 | |
5 | -use Woo\GridView\GridViewHelper; |
|
6 | - |
|
7 | 5 | class ActionsColumn extends BaseColumn |
8 | 6 | { |
9 | 7 | /** |
@@ -6,49 +6,49 @@ discard block |
||
6 | 6 | |
7 | 7 | class ActionsColumn extends BaseColumn |
8 | 8 | { |
9 | - /** |
|
10 | - * By default is empty for this column |
|
11 | - * @var string |
|
12 | - */ |
|
13 | - public $title = ''; |
|
9 | + /** |
|
10 | + * By default is empty for this column |
|
11 | + * @var string |
|
12 | + */ |
|
13 | + public $title = ''; |
|
14 | 14 | |
15 | - /** |
|
16 | - * Value contains short codes for actions |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - public $value = []; |
|
15 | + /** |
|
16 | + * Value contains short codes for actions |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + public $value = []; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - public $formatters = []; |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + public $formatters = []; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @return array |
|
28 | - */ |
|
29 | - protected function configTests(): array |
|
30 | - { |
|
31 | - return array_merge(parent::configTests(), [ |
|
32 | - 'value' => 'string', |
|
33 | - 'additionalActions' => 'array', |
|
34 | - 'actionsUrls' => 'any', |
|
35 | - ]); |
|
36 | - } |
|
26 | + /** |
|
27 | + * @return array |
|
28 | + */ |
|
29 | + protected function configTests(): array |
|
30 | + { |
|
31 | + return array_merge(parent::configTests(), [ |
|
32 | + 'value' => 'string', |
|
33 | + 'additionalActions' => 'array', |
|
34 | + 'actionsUrls' => 'any', |
|
35 | + ]); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - public function basicActions() |
|
42 | - { |
|
43 | - return [ |
|
44 | - 'show' => function($model) { |
|
45 | - return '<a href="' . call_user_func($this->actionsUrls, $model)['show'] . '">View</a>'; |
|
46 | - }, |
|
47 | - 'edit' => function($model) { |
|
48 | - return '<a href="' . call_user_func($this->actionsUrls, $model)['edit'] . '">Edit</a>'; |
|
49 | - }, |
|
50 | - 'delete' => function($model) { |
|
51 | - return ' |
|
38 | + /** |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + public function basicActions() |
|
42 | + { |
|
43 | + return [ |
|
44 | + 'show' => function($model) { |
|
45 | + return '<a href="' . call_user_func($this->actionsUrls, $model)['show'] . '">View</a>'; |
|
46 | + }, |
|
47 | + 'edit' => function($model) { |
|
48 | + return '<a href="' . call_user_func($this->actionsUrls, $model)['edit'] . '">Edit</a>'; |
|
49 | + }, |
|
50 | + 'delete' => function($model) { |
|
51 | + return ' |
|
52 | 52 | <form action="' . call_user_func($this->actionsUrls, $model)['delete'] . '" method="post" class="deleteForm"> |
53 | 53 | <input type="hidden" name="_token" value="' . csrf_token() . '"> |
54 | 54 | <input type="hidden" name="_method" value="DELETE"> |
@@ -57,27 +57,27 @@ discard block |
||
57 | 57 | >Delete</button> |
58 | 58 | </form> |
59 | 59 | '; |
60 | - }, |
|
61 | - ]; |
|
62 | - } |
|
60 | + }, |
|
61 | + ]; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @inheritdoc |
|
66 | - */ |
|
67 | - public function _renderValue($row) |
|
68 | - { |
|
69 | - $result = $this->value; |
|
64 | + /** |
|
65 | + * @inheritdoc |
|
66 | + */ |
|
67 | + public function _renderValue($row) |
|
68 | + { |
|
69 | + $result = $this->value; |
|
70 | 70 | |
71 | - $actions = array_merge($this->basicActions(), $this->additionalActions); |
|
71 | + $actions = array_merge($this->basicActions(), $this->additionalActions); |
|
72 | 72 | |
73 | - foreach ($actions as $key => $action) { |
|
74 | - if (strpos($result, '{' . $key . '}') === false) { |
|
75 | - continue; |
|
76 | - } |
|
73 | + foreach ($actions as $key => $action) { |
|
74 | + if (strpos($result, '{' . $key . '}') === false) { |
|
75 | + continue; |
|
76 | + } |
|
77 | 77 | |
78 | - $result = str_replace('{' . $key . '}', $action($row), $result); |
|
79 | - } |
|
78 | + $result = str_replace('{' . $key . '}', $action($row), $result); |
|
79 | + } |
|
80 | 80 | |
81 | - return $result; |
|
82 | - } |
|
81 | + return $result; |
|
82 | + } |
|
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | class UrlFormatter implements IFormatter |
6 | 6 | { |
7 | - public function format($value): string |
|
8 | - { |
|
9 | - return '<a href="' . htmlspecialchars($value, ENT_QUOTES) . '">' . htmlentities($value) . '</a>'; |
|
10 | - } |
|
7 | + public function format($value): string |
|
8 | + { |
|
9 | + return '<a href="' . htmlspecialchars($value, ENT_QUOTES) . '">' . htmlentities($value) . '</a>'; |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | class TextFormatter implements IFormatter |
6 | 6 | { |
7 | - public function format($value): string |
|
8 | - { |
|
9 | - return htmlentities($value); |
|
10 | - } |
|
7 | + public function format($value): string |
|
8 | + { |
|
9 | + return htmlentities($value); |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | class ImageFormatter implements IFormatter |
6 | 6 | { |
7 | - public function format($value): string |
|
8 | - { |
|
9 | - return '<img src="' . htmlspecialchars($value, ENT_QUOTES) . '">'; |
|
10 | - } |
|
7 | + public function format($value): string |
|
8 | + { |
|
9 | + return '<img src="' . htmlspecialchars($value, ENT_QUOTES) . '">'; |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface IFormatter |
6 | 6 | { |
7 | - public function format($value) : string; |
|
7 | + public function format($value) : string; |
|
8 | 8 | } |
9 | 9 | \ No newline at end of file |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | class EmailFormatter implements IFormatter |
6 | 6 | { |
7 | - public function format($value): string |
|
8 | - { |
|
9 | - return '<a href="mailto:' . htmlspecialchars($value, ENT_QUOTES) . '">' . htmlentities($value) . '</a>'; |
|
10 | - } |
|
7 | + public function format($value): string |
|
8 | + { |
|
9 | + return '<a href="mailto:' . htmlspecialchars($value, ENT_QUOTES) . '">' . htmlentities($value) . '</a>'; |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -17,13 +17,13 @@ |
||
17 | 17 | |
18 | 18 | require_once __DIR__ . '/functions.php'; |
19 | 19 | |
20 | - \Blade::directive('grid', function ($expression) { |
|
21 | - return "<?php echo grid($expression)->render() ?>"; |
|
22 | - }); |
|
20 | + \Blade::directive('grid', function ($expression) { |
|
21 | + return "<?php echo grid($expression)->render() ?>"; |
|
22 | + }); |
|
23 | 23 | |
24 | - $this->publishes([ |
|
25 | - __DIR__ . '/../public' => 'public/vendor/grid-view', |
|
26 | - ], 'public'); |
|
24 | + $this->publishes([ |
|
25 | + __DIR__ . '/../public' => 'public/vendor/grid-view', |
|
26 | + ], 'public'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function register() |
@@ -17,7 +17,7 @@ |
||
17 | 17 | |
18 | 18 | require_once __DIR__ . '/functions.php'; |
19 | 19 | |
20 | - \Blade::directive('grid', function ($expression) { |
|
20 | + \Blade::directive('grid', function($expression) { |
|
21 | 21 | return "<?php echo grid($expression)->render() ?>"; |
22 | 22 | }); |
23 | 23 |
@@ -7,21 +7,21 @@ |
||
7 | 7 | |
8 | 8 | abstract class BaseFilter |
9 | 9 | { |
10 | - use Configurable; |
|
10 | + use Configurable; |
|
11 | 11 | |
12 | - public $name; |
|
12 | + public $name; |
|
13 | 13 | |
14 | - public function __construct(array $config) |
|
15 | - { |
|
16 | - $this->loadConfig($config); |
|
17 | - } |
|
14 | + public function __construct(array $config) |
|
15 | + { |
|
16 | + $this->loadConfig($config); |
|
17 | + } |
|
18 | 18 | |
19 | - protected function configTests(): array |
|
20 | - { |
|
21 | - return [ |
|
22 | - 'name' => 'string', |
|
23 | - ]; |
|
24 | - } |
|
19 | + protected function configTests(): array |
|
20 | + { |
|
21 | + return [ |
|
22 | + 'name' => 'string', |
|
23 | + ]; |
|
24 | + } |
|
25 | 25 | |
26 | - abstract public function render(GridView $grid) : string; |
|
26 | + abstract public function render(GridView $grid) : string; |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class TextFilter extends BaseFilter |
8 | 8 | { |
9 | - public function render(GridView $grid): string |
|
10 | - { |
|
11 | - return view('woo_gridview::filters.text-filter', [ |
|
12 | - 'name' => $this->name, |
|
13 | - 'value' => $grid->getRequest()->filters[$this->name] ?? '', |
|
14 | - ]); |
|
15 | - } |
|
9 | + public function render(GridView $grid): string |
|
10 | + { |
|
11 | + return view('woo_gridview::filters.text-filter', [ |
|
12 | + 'name' => $this->name, |
|
13 | + 'value' => $grid->getRequest()->filters[$this->name] ?? '', |
|
14 | + ]); |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | \ No newline at end of file |