@@ -6,60 +6,60 @@ 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 = '{show} {edit} {delete}'; |
|
| 15 | + /** |
|
| 16 | + * Value contains short codes for actions |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + public $value = '{show} {edit} {delete}'; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Additional actions could be added, key is short-code and value is callback |
|
| 23 | - * @var array |
|
| 24 | - */ |
|
| 25 | - public $additionalActions = []; |
|
| 21 | + /** |
|
| 22 | + * Additional actions could be added, key is short-code and value is callback |
|
| 23 | + * @var array |
|
| 24 | + */ |
|
| 25 | + public $additionalActions = []; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var \Closure|null |
|
| 29 | - */ |
|
| 30 | - public $actionsUrls; |
|
| 27 | + /** |
|
| 28 | + * @var \Closure|null |
|
| 29 | + */ |
|
| 30 | + public $actionsUrls; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - public $contentFormat = 'raw'; |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + public $contentFormat = 'raw'; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @return array |
|
| 39 | - */ |
|
| 40 | - protected function configTests(): array |
|
| 41 | - { |
|
| 42 | - return array_merge(parent::configTests(), [ |
|
| 43 | - 'value' => 'string', |
|
| 44 | - 'additionalActions' => 'array', |
|
| 45 | - 'actionsUrls' => 'any', |
|
| 46 | - ]); |
|
| 47 | - } |
|
| 37 | + /** |
|
| 38 | + * @return array |
|
| 39 | + */ |
|
| 40 | + protected function configTests(): array |
|
| 41 | + { |
|
| 42 | + return array_merge(parent::configTests(), [ |
|
| 43 | + 'value' => 'string', |
|
| 44 | + 'additionalActions' => 'array', |
|
| 45 | + 'actionsUrls' => 'any', |
|
| 46 | + ]); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @return array |
|
| 51 | - */ |
|
| 52 | - public function basicActions() |
|
| 53 | - { |
|
| 54 | - return [ |
|
| 55 | - 'show' => function($model) { |
|
| 56 | - return '<a href="' . call_user_func($this->actionsUrls, $model)['show'] . '">View</a>'; |
|
| 57 | - }, |
|
| 58 | - 'edit' => function($model) { |
|
| 59 | - return '<a href="' . call_user_func($this->actionsUrls, $model)['edit'] . '">Edit</a>'; |
|
| 60 | - }, |
|
| 61 | - 'delete' => function($model) { |
|
| 62 | - return ' |
|
| 49 | + /** |
|
| 50 | + * @return array |
|
| 51 | + */ |
|
| 52 | + public function basicActions() |
|
| 53 | + { |
|
| 54 | + return [ |
|
| 55 | + 'show' => function($model) { |
|
| 56 | + return '<a href="' . call_user_func($this->actionsUrls, $model)['show'] . '">View</a>'; |
|
| 57 | + }, |
|
| 58 | + 'edit' => function($model) { |
|
| 59 | + return '<a href="' . call_user_func($this->actionsUrls, $model)['edit'] . '">Edit</a>'; |
|
| 60 | + }, |
|
| 61 | + 'delete' => function($model) { |
|
| 62 | + return ' |
|
| 63 | 63 | <form action="' . call_user_func($this->actionsUrls, $model)['delete'] . '" method="post" class="deleteForm"> |
| 64 | 64 | <input type="hidden" name="_token" value="' . csrf_token() . '"> |
| 65 | 65 | <input type="hidden" name="_method" value="DELETE"> |
@@ -68,27 +68,27 @@ discard block |
||
| 68 | 68 | >Delete</button> |
| 69 | 69 | </form> |
| 70 | 70 | '; |
| 71 | - }, |
|
| 72 | - ]; |
|
| 73 | - } |
|
| 71 | + }, |
|
| 72 | + ]; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @inheritdoc |
|
| 77 | - */ |
|
| 78 | - public function _renderValue($row) |
|
| 79 | - { |
|
| 80 | - $result = $this->value; |
|
| 75 | + /** |
|
| 76 | + * @inheritdoc |
|
| 77 | + */ |
|
| 78 | + public function _renderValue($row) |
|
| 79 | + { |
|
| 80 | + $result = $this->value; |
|
| 81 | 81 | |
| 82 | - $actions = array_merge($this->basicActions(), $this->additionalActions); |
|
| 82 | + $actions = array_merge($this->basicActions(), $this->additionalActions); |
|
| 83 | 83 | |
| 84 | - foreach ($actions as $key => $action) { |
|
| 85 | - if (strpos($result, '{' . $key . '}') === false) { |
|
| 86 | - continue; |
|
| 87 | - } |
|
| 84 | + foreach ($actions as $key => $action) { |
|
| 85 | + if (strpos($result, '{' . $key . '}') === false) { |
|
| 86 | + continue; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - $result = str_replace('{' . $key . '}', $action($row), $result); |
|
| 90 | - } |
|
| 89 | + $result = str_replace('{' . $key . '}', $action($row), $result); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return $result; |
|
| 93 | - } |
|
| 92 | + return $result; |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | \ No newline at end of file |